Merge remote-tracking branch 'origin/test' into hph
This commit is contained in:
8
pom.xml
8
pom.xml
@@ -212,6 +212,14 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- alipay -->
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>4.39.208.ALL</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<!-- <profiles>-->
|
||||
<!-- <profile>-->
|
||||
|
||||
@@ -26,7 +26,7 @@ public class MemberController {
|
||||
@RequestHeader("clientType") String clientType,
|
||||
@RequestParam("shopId") String shopId,
|
||||
@RequestParam("phone") String phone,
|
||||
@RequestParam("isFlag") String isFlag,
|
||||
@RequestParam(value = "isFlag",required = false,defaultValue = "0") String isFlag,
|
||||
@RequestParam("page") int page,
|
||||
@RequestParam("pageSize") int pageSize
|
||||
) {
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
||||
import com.alipay.api.request.AlipayUserInfoShareRequest;
|
||||
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
||||
import com.alipay.api.response.AlipayUserInfoShareResponse;
|
||||
import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
|
||||
@@ -10,14 +18,18 @@ import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.IpUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.RedisCst;
|
||||
import com.chaozhanggui.system.cashierservice.util.WechatUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@RestController
|
||||
@@ -278,4 +290,98 @@ public class PayController {
|
||||
){
|
||||
return payService.getOrderDiscount(staffId, orderId, token);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("pcscanpay")
|
||||
@LimitSubmit(key = "pcscanpay:%s")
|
||||
public Result pcscanpay(HttpServletRequest request,@RequestBody PaymentReq paymentReq){
|
||||
try {
|
||||
return payService.pcscanpay(paymentReq.getOrderId(),IpUtil.getIpAddr(request),paymentReq.getUserId(),paymentReq.getPayType());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Result.fail(CodeEnum.FAIL);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("createOrder")
|
||||
public Result createOrder(HttpServletRequest request,@RequestBody PaymentReq paymentReq){
|
||||
try {
|
||||
return payService.createOrder(IpUtil.getIpAddr(request),paymentReq.getUserId(),paymentReq.getPayType(),paymentReq.getShopId(),paymentReq.getPayAmount());
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Result.fail(CodeEnum.FAIL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Value("${wx.ysk.appId}")
|
||||
private String appId;
|
||||
|
||||
@Value("${wx.ysk.secrete}")
|
||||
private String secrete;
|
||||
|
||||
|
||||
|
||||
@Value("${ali.appId}")
|
||||
private String aliAppId;
|
||||
|
||||
@Value("${ali.privateKey}")
|
||||
private String privateKey;
|
||||
|
||||
@Value("${ali.publicKey}")
|
||||
private String publicKey;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取支付宝或微信openId
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/openId")
|
||||
public Result getOpenId(
|
||||
@RequestParam String code,
|
||||
@RequestParam String payType
|
||||
) throws AlipayApiException {
|
||||
|
||||
if("WECHAT".equals(payType)){
|
||||
JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, appId, secrete);
|
||||
log.info("SessionKeyOpenId:{}",SessionKeyOpenId.toString());
|
||||
String openid = SessionKeyOpenId.getString("openid");
|
||||
if(Objects.isNull(openid)){
|
||||
return Result.fail("获取微信id失败");
|
||||
}
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS,openid);
|
||||
}else if("ALIPAY".equals(payType)){
|
||||
|
||||
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",aliAppId,privateKey,"json","GBK",publicKey,"RSA2");
|
||||
AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest();
|
||||
AlipayUserInfoShareResponse response = alipayClient.execute(request,code);
|
||||
log.info("AlipayUserInfoShareResponse:{}",JSONObject.toJSONString(response));
|
||||
if(!response.isSuccess()){
|
||||
return Result.fail("获取支付宝userId失败");
|
||||
}
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS,response.getUserId());
|
||||
}
|
||||
|
||||
return Result.fail(CodeEnum.FAIL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,4 +15,6 @@ public class OrderVo {
|
||||
private String tableId;
|
||||
private Integer vipUserId;
|
||||
private Integer type;
|
||||
|
||||
private String sendType;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -37,7 +38,8 @@ public class TbOrderDetail implements Serializable {
|
||||
private BigDecimal priceAmount;
|
||||
private BigDecimal packAmount;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String remark;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ToString
|
||||
public class TbPrintMachine implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ToString
|
||||
public class TbPrintMachineWithBLOBs extends TbPrintMachine implements Serializable {
|
||||
private String config;
|
||||
|
||||
@@ -24,4 +27,4 @@ public class TbPrintMachineWithBLOBs extends TbPrintMachine implements Serializa
|
||||
public void setCategoryList(String categoryList) {
|
||||
this.categoryList = categoryList == null ? null : categoryList.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,13 +86,6 @@ public class LimitSubmitAspect {
|
||||
Object[] args= joinPoint.getArgs();
|
||||
String orderId=orderId(method,args);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
LimitSubmit limitSubmit = method.getAnnotation(LimitSubmit.class);
|
||||
String redisKey = limitSubmit.key();
|
||||
String key = getRedisKey1(joinPoint, redisKey,orderId);
|
||||
@@ -205,6 +198,13 @@ public class LimitSubmitAspect {
|
||||
if(o instanceof List){
|
||||
orderId= ((List<TbOrderDetail>)o).get(0).getOrderId().toString();
|
||||
}
|
||||
}else if("pcscanpay".equals(method.getName())){
|
||||
Object o=args[1];
|
||||
|
||||
if(o instanceof PaymentReq){
|
||||
orderId=((PaymentReq)o).getOrderId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return orderId;
|
||||
|
||||
@@ -28,6 +28,9 @@ public class WebAppConfigurer implements WebMvcConfigurer {
|
||||
.excludePathPatterns("/order/sendMessage")
|
||||
.excludePathPatterns("/order/getOrderById")
|
||||
.excludePathPatterns("/data/handoverprint")
|
||||
.excludePathPatterns("/pay/pcscanpay")
|
||||
.excludePathPatterns("/pay/openId")
|
||||
.excludePathPatterns("/pay/createOrder")
|
||||
;
|
||||
|
||||
|
||||
|
||||
@@ -22,5 +22,12 @@ public class PaymentReq implements Serializable {
|
||||
|
||||
private String memberCode;
|
||||
|
||||
private String payType;
|
||||
|
||||
private String userId;
|
||||
|
||||
private String shopId;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.chaozhanggui.system.cashierservice.mybatis;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
||||
|
||||
public interface MPOrderDetailMapper extends BaseMapper<TbOrderDetail> {
|
||||
}
|
||||
@@ -0,0 +1,459 @@
|
||||
package com.chaozhanggui.system.cashierservice.rabbit;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
|
||||
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
|
||||
import com.chaozhanggui.system.cashierservice.mybatis.MPOrderDetailMapper;
|
||||
import com.chaozhanggui.system.cashierservice.mybatis.MpPrintMachineMapper;
|
||||
import com.chaozhanggui.system.cashierservice.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@Service
|
||||
public class PrintConsumer {
|
||||
|
||||
|
||||
@Autowired
|
||||
TbShopUserMapper tbShopUserMapper;
|
||||
@Autowired
|
||||
private TbOrderInfoMapper tbOrderInfoMapper;
|
||||
@Autowired
|
||||
private TbPrintMachineMapper tbPrintMachineMapper;
|
||||
@Autowired
|
||||
private TbCashierCartMapper tbCashierCartMapper;
|
||||
@Autowired
|
||||
private TbProductSkuMapper tbProductSkuMapper;
|
||||
@Autowired
|
||||
private TbShopInfoMapper tbShopInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private TbProductMapper tbProductMapper;
|
||||
|
||||
@Autowired
|
||||
private TbOrderDetailMapper tbOrderDetailMapper;
|
||||
@Autowired
|
||||
|
||||
private RedisUtil redisUtils;
|
||||
|
||||
private final RedisTemplate<String, Object> redisTemplate;
|
||||
@Autowired
|
||||
private MpPrintMachineMapper mpPrintMachineMapper;
|
||||
@Autowired
|
||||
private MPOrderDetailMapper mPOrderDetailMapper;
|
||||
|
||||
public PrintConsumer(RedisTemplate<String, Object> redisTemplate) {
|
||||
this.redisTemplate = redisTemplate;
|
||||
}
|
||||
|
||||
@RabbitListener(queues = {RabbitConstants.QUEUE_PRINT_DISHES})
|
||||
public void printDishesListener(JSONObject jsonObject) {
|
||||
try {
|
||||
log.info("打印消息mq 接收到打印菜品消息,消息内容: {}", jsonObject);
|
||||
Integer orderId = jsonObject.getInteger("orderId");
|
||||
JSONArray orderDetailIds = jsonObject.getJSONArray("orderDetailIds");
|
||||
Boolean isReturn = jsonObject.getBoolean("isReturn");
|
||||
|
||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
|
||||
if (ObjectUtil.isEmpty(orderInfo)) {
|
||||
log.error("没有对应的订单信息");
|
||||
return;
|
||||
}
|
||||
List<TbOrderDetail> orderDetails = mPOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.in(TbOrderDetail::getId, orderDetailIds));
|
||||
getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "cash").forEach(machine -> {
|
||||
log.info("打印机信息: {}", machine);
|
||||
JSONObject config = JSONObject.parseObject(machine.getConfig());
|
||||
String model = config.getString("model");
|
||||
if (!"one".equals(model)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(), CategoryInfo.class);
|
||||
orderDetails.forEach(item -> {
|
||||
printDishesTicket(isReturn, machine, item, orderInfo, categoryInfos);
|
||||
});
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
log.warn("打印菜品失败", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RabbitListener(queues = {RabbitConstants.QUEUE_PRINT_PLACE})
|
||||
public void printPlaceListener(JSONObject jsonObject) {
|
||||
try {
|
||||
log.info("打印消息mq 接收到打印结算单消息,消息内容: {}", jsonObject);
|
||||
Integer orderId = jsonObject.getInteger("orderId");
|
||||
Boolean isReturn = jsonObject.getBoolean("isReturn");
|
||||
|
||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
|
||||
if (ObjectUtil.isEmpty(orderInfo)) {
|
||||
log.error("没有对应的订单信息");
|
||||
return;
|
||||
}
|
||||
|
||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
|
||||
if (shopInfo == null) {
|
||||
log.error("店铺信息不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
getPrintMachine(shopInfo.getId(), "cash").forEach(machine -> {
|
||||
log.info("打印机信息: {}", machine);
|
||||
JSONObject config = JSONObject.parseObject(machine.getConfig());
|
||||
String model = config.getString("model");
|
||||
if (!"normal".equals(model)) {
|
||||
return;
|
||||
}
|
||||
printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
log.warn("打印菜品失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<TbPrintMachine> getPrintMachine(Integer shopId, String subType) {
|
||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId);
|
||||
if (ObjectUtil.isEmpty(shopInfo)) {
|
||||
log.error("店铺信息不存在");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<TbPrintMachine> list = mpPrintMachineMapper.selectList(new LambdaQueryWrapper<TbPrintMachine>()
|
||||
.eq(TbPrintMachine::getStatus, 1)
|
||||
.eq(TbPrintMachine::getShopId, shopId)
|
||||
.eq(TbPrintMachine::getSubType, subType)
|
||||
.eq(TbPrintMachine::getConnectionType, "network"));
|
||||
if (list.isEmpty()) {
|
||||
log.error("店铺未配置打印机,店铺id: {}", shopId);
|
||||
return list;
|
||||
}
|
||||
log.info("打印机列表: {}", list);
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 打印菜品单
|
||||
*
|
||||
* @param isReturn 是否退款单
|
||||
*/
|
||||
private void printDishesTicket(boolean isReturn, TbPrintMachine tbPrintMachineWithBLOBs, TbOrderDetail item, TbOrderInfo orderInfo, List<CategoryInfo> categoryInfos) {
|
||||
log.info("开始打印一菜一品票据,商品名:{}", item.getProductName());
|
||||
if (item.getProductId().equals(-999)) {
|
||||
return;
|
||||
}
|
||||
String categoryId = tbProductMapper.selectByPrimaryKey(item.getProductId()).getCategoryId();
|
||||
TbProductSkuWithBLOBs sku = tbProductSkuMapper.selectByPrimaryKey(item.getProductSkuId());
|
||||
if (sku == null) {
|
||||
log.error("商品不存在, id: {}", item.getProductSkuId());
|
||||
return;
|
||||
}
|
||||
|
||||
long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count == 0) {
|
||||
log.warn("分类未添加菜品: {} : {}", item.getProductName(), sku.getSpecSnap());
|
||||
return;
|
||||
}
|
||||
|
||||
String remark = StrUtil.isNotBlank(sku.getSpecSnap()) ? sku.getSpecSnap() : "";
|
||||
item.setRemark(remark);
|
||||
|
||||
String data;
|
||||
String voiceJson;
|
||||
if (isReturn) {
|
||||
|
||||
data = PrinterUtils.getPrintData("return",
|
||||
StrUtil.isBlank(orderInfo.getTableName()) ? orderInfo.getMasterId() : orderInfo.getTableName(),
|
||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), item.getProductName(), Math.abs(item.getNum()), remark);
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
|
||||
} else {
|
||||
data = PrinterUtils.getPrintData("", orderInfo.getMasterId(),
|
||||
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), item.getProductName(),
|
||||
item.getNum(), remark);
|
||||
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印结算单
|
||||
*/
|
||||
private void printPlaceTicket(boolean isReturn, TbPrintMachine printMachine, TbOrderInfo orderInfo, TbShopInfo shopInfo) {
|
||||
|
||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId());
|
||||
if (!tbOrderDetails.isEmpty()) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
tbOrderDetails.parallelStream().forEach(it -> {
|
||||
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
|
||||
});
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!detailList.isEmpty()) {
|
||||
if (isReturn) {
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
|
||||
ObjectUtil.isEmpty(orderInfo.getMasterId()) ||
|
||||
ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(),
|
||||
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
|
||||
"【POS-1】001", orderInfo.getPayAmount().toPlainString(), balance, orderInfo.getPayType(),
|
||||
"0", detailList, orderInfo.getRemark(), null, null);
|
||||
|
||||
String printType = "退款单";
|
||||
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 1, 1, printMachine.getAddress(), data);
|
||||
} else {
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印",
|
||||
orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(),
|
||||
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
|
||||
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
|
||||
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
|
||||
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() != null ? orderInfo.getDiscountAmount().toPlainString() : null,
|
||||
orderInfo.getDiscountRatio() != null ? orderInfo.getDiscountRatio().toPlainString() : null);
|
||||
detailPO.setOutNumber(orderInfo.getOutNumber());
|
||||
String printType = "结算单";
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, printMachine.getAddress(), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void fePrinter(TbPrintMachine tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
|
||||
String orderId = orderInfo.getId().toString();
|
||||
switch (tbPrintMachineWithBLOBs.getSubType()) {
|
||||
case "label": //标签打印机
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
log.info("获取当前类别是否未打印类别:{}", count);
|
||||
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
for (int i = 0; i < it.getNumber(); i++) {
|
||||
FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
case "cash": //小票打印机
|
||||
switch (model) {
|
||||
case "normal": //普通出单
|
||||
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||
if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
tbOrderDetails.parallelStream().forEach(it -> {
|
||||
String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
log.info("获取当前类别是否未打印类别:{}", count);
|
||||
|
||||
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
|
||||
});
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList);
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio().toPlainString());
|
||||
|
||||
String printType = "退款单";
|
||||
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
|
||||
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
// PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
|
||||
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark);
|
||||
detailList.add(detail);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
String balance = "0";
|
||||
|
||||
if ("deposit".equals(orderInfo.getPayType())) {
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMemberId()));
|
||||
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) {
|
||||
balance = user.getAmount().toPlainString();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) {
|
||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark(), null, null);
|
||||
String printType = "结算单";
|
||||
|
||||
if ("return".equals(orderInfo.getOrderType())) {
|
||||
printType = "退款单";
|
||||
}
|
||||
|
||||
|
||||
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case "one": //一菜一品
|
||||
|
||||
if (!orderInfo.getStatus().equals("unpaid")) {
|
||||
return;
|
||||
}
|
||||
|
||||
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
|
||||
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
|
||||
|
||||
cashierCarts.parallelStream().forEach(it -> {
|
||||
|
||||
String categoryId;
|
||||
if (ObjectUtil.isEmpty(it.getCategoryId())) {
|
||||
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
} else {
|
||||
categoryId = it.getCategoryId();
|
||||
}
|
||||
|
||||
|
||||
Long count = categoryInfos.stream().filter(c ->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if (count > 0) {
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
|
||||
|
||||
FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "category": //分类出单
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case "kitchen": //出品打印机
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -15,20 +15,20 @@ import org.springframework.context.annotation.Scope;
|
||||
|
||||
@Configuration
|
||||
public class RabbitConfig {
|
||||
|
||||
|
||||
@Value("${spring.rabbitmq.host}")
|
||||
private String host;
|
||||
|
||||
|
||||
@Value("${spring.rabbitmq.port}")
|
||||
private int port;
|
||||
|
||||
|
||||
@Value("${spring.rabbitmq.username}")
|
||||
private String username;
|
||||
|
||||
|
||||
@Value("${spring.rabbitmq.password}")
|
||||
private String password;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public ConnectionFactory connectionFactory() {
|
||||
@@ -39,7 +39,7 @@ public class RabbitConfig {
|
||||
connectionFactory.setPublisherConfirms(true);
|
||||
return connectionFactory;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
//必须是prototype类型
|
||||
@@ -51,12 +51,12 @@ public class RabbitConfig {
|
||||
public DirectExchange defaultExchange_Register() {
|
||||
return new DirectExchange(RabbitConstants.CART_ORDER_COLLECT_PUT);
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public Queue queuePut_Register() {
|
||||
return new Queue(RabbitConstants.CART_ORDER_COLLECT_QUEUE_PUT, true); //队列持久
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public Binding bindingPut_Register() {
|
||||
return BindingBuilder.bind(queuePut_Register()).to(defaultExchange_Register()).with(RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT);
|
||||
@@ -142,7 +142,28 @@ public class RabbitConfig {
|
||||
}
|
||||
|
||||
|
||||
// 打印出票
|
||||
@Bean
|
||||
DirectExchange printExchange() {
|
||||
return new DirectExchange(RabbitConstants.EXCHANGE_PRINT);
|
||||
}
|
||||
|
||||
@Bean
|
||||
Queue printDishesQueue() {
|
||||
return new Queue(RabbitConstants.QUEUE_PRINT_DISHES);
|
||||
}
|
||||
@Bean
|
||||
Binding bindingDishedPrint(Queue printDishesQueue, DirectExchange printExchange) {
|
||||
return BindingBuilder.bind(printDishesQueue).to(printExchange).with(RabbitConstants.ROUTING_KEY_PRINT_DISHES);
|
||||
}
|
||||
|
||||
@Bean
|
||||
Queue printPlaceQueue() {
|
||||
return new Queue(RabbitConstants.QUEUE_PRINT_PLACE);
|
||||
}
|
||||
@Bean
|
||||
Binding bindingPlacePrint(Queue printPlaceQueue, DirectExchange printExchange) {
|
||||
return BindingBuilder.bind(printPlaceQueue).to(printExchange).with(RabbitConstants.ROUTING_KEY_PRINT_PLACE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,4 +58,13 @@ public interface RabbitConstants {
|
||||
public static final String BALANCE_QUEUE_PUT="balance_queue_put";
|
||||
|
||||
public static final String BALANCE_ROUTINGKEY_PUT="balance_routingkey_put";
|
||||
|
||||
// 打印出票
|
||||
String EXCHANGE_PRINT = "exchange.print";
|
||||
// 菜品打印
|
||||
String QUEUE_PRINT_DISHES = "queue.dishes.print";
|
||||
String ROUTING_KEY_PRINT_DISHES = "routing.dishes.print";
|
||||
// 下单打印
|
||||
String QUEUE_PRINT_PLACE = "queue.place.order.print";
|
||||
String ROUTING_KEY_PRINT_PLACE = "routing.place.order.print";
|
||||
}
|
||||
|
||||
@@ -92,6 +92,8 @@ public class MemberService {
|
||||
if(!"1".equals(isFlag)){
|
||||
isFlag=null;
|
||||
}
|
||||
|
||||
|
||||
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopId(shopId, phone,isFlag);
|
||||
PageInfo pageInfo = new PageInfo(tbShopUsers);
|
||||
return Result.success(CodeEnum.SUCCESS, pageInfo);
|
||||
|
||||
@@ -634,14 +634,14 @@ public class OrderService {
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result createOrder(OrderVo orderVo, String clientType, String token, Integer oldOrderId, boolean isPrint) {
|
||||
public Result createOrder(OrderVo orderVo, String clientType, String token, Integer oldOrderId, boolean isPost) {
|
||||
String day = DateUtils.getDay();
|
||||
TbShopTable shopTable = null;
|
||||
|
||||
String currentOrderKey = RedisCst.getCurrentOrderKey(orderVo.getTableId(),
|
||||
orderVo.getShopId().toString());
|
||||
String orderIdValue = redisUtil.getMessage(currentOrderKey);
|
||||
Integer orderId = orderIdValue == null ? 0 : Integer.parseInt(orderIdValue);
|
||||
Integer orderId = isPost ? orderIdValue == null ? 0 : Integer.parseInt(orderIdValue) : 0;
|
||||
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, orderVo.getShopId())
|
||||
@@ -717,15 +717,27 @@ public class OrderService {
|
||||
|
||||
for (TbCashierCart cashierCart : list) {
|
||||
|
||||
|
||||
TbOrderDetail orderDetail = new TbOrderDetail();
|
||||
TbProductWithBLOBs product=tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
|
||||
if("takeaway".equals(orderVo.getSendType())||"takeself".equals(orderVo.getSendType())){
|
||||
if(Objects.nonNull(product.getPackFee())){
|
||||
packAMount = packAMount.add(product.getPackFee());
|
||||
orderDetail.setPackAmount(product.getPackFee());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
TbProductSkuWithBLOBs tbProduct = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId()));
|
||||
totalAmount = totalAmount.add(cashierCart.getTotalAmount());
|
||||
packAMount = packAMount.add(cashierCart.getPackFee());
|
||||
|
||||
feeAmount = cashierCart.getPackFee();
|
||||
if (Objects.nonNull(tbProduct)) {
|
||||
saleAmount = saleAmount.add(tbProduct.getSalePrice());
|
||||
}
|
||||
skuMap.put(tbProduct.getId(), tbProduct);
|
||||
TbOrderDetail orderDetail = new TbOrderDetail();
|
||||
|
||||
orderDetail.setCreateTime(new Date());
|
||||
orderDetail.setNum(cashierCart.getNumber());
|
||||
orderDetail.setPrice(cashierCart.getSalePrice());
|
||||
@@ -739,7 +751,6 @@ public class OrderService {
|
||||
orderDetail.setProductSkuName(tbProduct.getSpecSnap());
|
||||
orderDetail.setProductName(cashierCart.getName());
|
||||
orderDetail.setShopId(orderVo.getShopId());
|
||||
orderDetail.setPackAmount(cashierCart.getPackFee());
|
||||
orderDetail.setStatus("unpaid");
|
||||
orderDetail.setProductImg(cashierCart.getCoverImg());
|
||||
masterId = cashierCart.getMasterId();
|
||||
@@ -754,7 +765,7 @@ public class OrderService {
|
||||
if (orderInfo == null || !"unpaid".equals(orderInfo.getStatus())) {
|
||||
redisUtil.deleteByKey(currentOrderKey);
|
||||
}
|
||||
if (orderId > 0 && orderInfo != null) {
|
||||
if (orderInfo != null && orderId > 0) {
|
||||
// if (!orderInfo.getStatus().equals("unpaid")){
|
||||
// return Result.fail(CodeEnum.ORDERCREATE);
|
||||
// }
|
||||
@@ -774,10 +785,11 @@ public class OrderService {
|
||||
orderInfo.setTradeDay(DateUtils.getDay());
|
||||
orderInfo.setUserId(orderVo.getUserId());
|
||||
orderInfo.setUseType(StrUtil.isNotBlank(orderVo.getTableId()) ? "postPay" : "afterPay");
|
||||
orderInfo.setPackFee(packAMount);
|
||||
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
} else {
|
||||
orderInfo = new TbOrderInfo(orderNo, totalAmount, packAMount, totalAmount, saleAmount, totalAmount, feeAmount, "",
|
||||
"table", "cash", orderVo.getMerchantId().toString(), orderVo.getShopId().toString(),
|
||||
orderVo.getSendType(), "cash", orderVo.getMerchantId().toString(), orderVo.getShopId().toString(),
|
||||
"", (byte) 1, day, masterId);
|
||||
orderInfo.setMasterId(orderVo.getMasterId());
|
||||
orderInfo.setRemark(orderVo.getRemark());
|
||||
@@ -818,7 +830,9 @@ public class OrderService {
|
||||
redisUtil.saveMessage(RedisCst.OUT_NUMBER.concat(orderInfo.getShopId()),object.toString());
|
||||
orderId = orderInfo.getId();
|
||||
|
||||
redisUtil.saveMessage(currentOrderKey, orderInfo.getId().toString());
|
||||
if (isPost) {
|
||||
redisUtil.saveMessage(currentOrderKey, orderInfo.getId().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -871,7 +885,7 @@ public class OrderService {
|
||||
}
|
||||
|
||||
if (!StrUtil.isBlank(orderVo.getTableId())) {
|
||||
if (isPrint) {
|
||||
if (isPost) {
|
||||
producer.printMechine(String.valueOf(orderId));
|
||||
}
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
@@ -947,11 +961,11 @@ public class OrderService {
|
||||
orderCode =String.valueOf(Integer.valueOf(code)+1);
|
||||
}
|
||||
redisUtil.getIncrNum("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "2");
|
||||
boolean flag = redisUtil.execsSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day,orderCode);
|
||||
if (flag){
|
||||
return generateOrderCode(day,clientType,shopId);
|
||||
}
|
||||
// 增加计数器
|
||||
// boolean flag = redisUtil.execsSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day,orderCode);
|
||||
// if (flag){
|
||||
// return generateOrderCode(day,clientType,shopId);
|
||||
// }
|
||||
// 增加计数器
|
||||
|
||||
return orderCode;
|
||||
}
|
||||
|
||||
@@ -24,10 +24,13 @@ import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.thirdpay.resp.*;
|
||||
import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService;
|
||||
import com.chaozhanggui.system.cashierservice.util.*;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -37,6 +40,7 @@ import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.ACCOUNTEIXST;
|
||||
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.SUCCESS;
|
||||
@@ -132,11 +136,28 @@ public class PayService {
|
||||
@Autowired
|
||||
private MpShopTableMapper mpShopTableMapper;
|
||||
|
||||
private final RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
public PayService(RedisTemplate<String, Object> redisTemplate) {
|
||||
this.redisTemplate = redisTemplate;
|
||||
}
|
||||
|
||||
|
||||
public Result queryPayType(String shopId) {
|
||||
return Result.success(CodeEnum.SUCCESS, tbShopPayTypeMapper.selectByShopId(shopId));
|
||||
}
|
||||
|
||||
private void clearTableInfoCache(TbOrderInfo orderInfo) {
|
||||
if (StrUtil.isNotBlank(orderInfo.getTableId())) {
|
||||
String currentOrderKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
|
||||
orderInfo.getShopId());
|
||||
redisTemplate.delete(currentOrderKey);
|
||||
}
|
||||
String printKey = RedisCst.ORDER_PRINT_PRO + orderInfo.getId();
|
||||
// 重置打印数据
|
||||
redisTemplate.delete(printKey);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result scanPay(String orderId, String authCode, String ip, String token, BigDecimal payAmount, BigDecimal discountAmount) {
|
||||
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(authCode) || ObjectUtil.isEmpty(ip)) {
|
||||
@@ -304,6 +325,7 @@ public class PayService {
|
||||
orderInfo.getShopId());
|
||||
redisUtil.del(tableCartKey);
|
||||
|
||||
clearTableInfoCache(orderInfo);
|
||||
return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data"));
|
||||
} else {
|
||||
String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null;
|
||||
@@ -326,6 +348,8 @@ public class PayService {
|
||||
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
|
||||
orderInfo.getShopId());
|
||||
redisUtil.del(tableCartKey);
|
||||
clearTableInfoCache(orderInfo);
|
||||
|
||||
return Result.success(CodeEnum.PAYING);
|
||||
}
|
||||
// orderInfo.setStatus("fail");
|
||||
@@ -385,6 +409,7 @@ public class PayService {
|
||||
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
|
||||
orderInfo.getShopId());
|
||||
redisUtil.del(tableCartKey);
|
||||
clearTableInfoCache(orderInfo);
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS, mainScanResp);
|
||||
} else if ("TRADE_AWAIT".equals(mainScanResp.getState())) {
|
||||
@@ -404,6 +429,8 @@ public class PayService {
|
||||
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
|
||||
orderInfo.getShopId());
|
||||
redisUtil.del(tableCartKey);
|
||||
clearTableInfoCache(orderInfo);
|
||||
|
||||
return Result.success(CodeEnum.PAYING);
|
||||
}
|
||||
}
|
||||
@@ -657,6 +684,7 @@ public class PayService {
|
||||
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
|
||||
orderInfo.getShopId());
|
||||
redisUtil.del(tableCartKey);
|
||||
clearTableInfoCache(orderInfo);
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
@@ -785,6 +813,7 @@ public class PayService {
|
||||
baObj.put("type","消费");
|
||||
baObj.put("time",flow.getCreateTime());
|
||||
producer.balance(baObj.toString());
|
||||
clearTableInfoCache(orderInfo);
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
@@ -891,6 +920,8 @@ public class PayService {
|
||||
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
|
||||
orderInfo.getShopId());
|
||||
redisUtil.del(tableCartKey);
|
||||
clearTableInfoCache(orderInfo);
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@@ -984,6 +1015,7 @@ public class PayService {
|
||||
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
|
||||
orderInfo.getShopId());
|
||||
redisUtil.del(tableCartKey);
|
||||
clearTableInfoCache(orderInfo);
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
@@ -1069,6 +1101,8 @@ public class PayService {
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
|
||||
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
|
||||
clearTableInfoCache(orderInfo);
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1706,6 +1740,294 @@ public class PayService {
|
||||
}
|
||||
|
||||
|
||||
public Result pcscanpay(String orderId,String ip,String userId,String payType) throws JsonProcessingException {
|
||||
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(ip)) {
|
||||
return Result.fail(CodeEnum.PARAM);
|
||||
}
|
||||
|
||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
||||
|
||||
if (ObjectUtil.isEmpty(orderInfo)) {
|
||||
return Result.fail(CodeEnum.ORDERNOEXIST);
|
||||
}
|
||||
|
||||
|
||||
if (!"unpaid".equals(orderInfo.getStatus()) && !"paying".equals(orderInfo.getStatus())) {
|
||||
return Result.fail(CodeEnum.ORDERSTATUSERROR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null);
|
||||
if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) {
|
||||
return Result.fail(CodeEnum.CARTEXIST);
|
||||
}
|
||||
|
||||
StringBuffer body = new StringBuffer();
|
||||
for (TbCashierCart cashierCart : cashierCarts) {
|
||||
body.append(cashierCart.getName());
|
||||
}
|
||||
if (ObjectUtil.isNull(orderInfo.getMerchantId()) || ObjectUtil.isEmpty(orderInfo.getMerchantId())) {
|
||||
return Result.fail(CodeEnum.NOCUSTOMER);
|
||||
}
|
||||
|
||||
|
||||
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
|
||||
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
||||
return Result.fail(CodeEnum.NOCUSTOMER);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderId);
|
||||
if (ObjectUtil.isEmpty(payment) || payment == null) {
|
||||
payment = new TbOrderPayment();
|
||||
payment.setPayTypeId("ysk");
|
||||
payment.setAmount(orderInfo.getOrderAmount());
|
||||
payment.setPaidAmount(orderInfo.getPayAmount());
|
||||
payment.setHasRefundAmount(BigDecimal.ZERO);
|
||||
payment.setReceived(payment.getAmount());
|
||||
payment.setChangeFee(BigDecimal.ZERO);
|
||||
payment.setMemberId(orderInfo.getMemberId());
|
||||
payment.setShopId(orderInfo.getShopId());
|
||||
payment.setOrderId(orderInfo.getId().toString());
|
||||
payment.setCreatedAt(System.currentTimeMillis());
|
||||
payment.setAuthCode("");
|
||||
tbOrderPaymentMapper.insert(payment);
|
||||
} else {
|
||||
payment.setAuthCode("");
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
tbOrderPaymentMapper.updateByPrimaryKey(payment);
|
||||
}
|
||||
|
||||
|
||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||
orderInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
|
||||
|
||||
String reqbody = "";
|
||||
|
||||
if (body.length() > 15) {
|
||||
reqbody = body.substring(0, 6).concat("....").concat(body.substring(body.length() - 6, body.length()));
|
||||
} else {
|
||||
reqbody = body.toString();
|
||||
}
|
||||
|
||||
PublicResp<JspayResp> publicResp = thirdPayService.jspay(url,thirdApply.getAppId(),thirdApply.getAppToken(),reqbody,reqbody,orderInfo.getOrderAmount().multiply(new BigDecimal(100)).longValue(),payType,"WECHAT".equals(payType)?thirdApply.getSmallAppid():null,userId,ip,DateUtils.getSsdfTimes(),thirdApply.getStoreId(),backUrl,backUrl);
|
||||
|
||||
|
||||
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
||||
if ("000000".equals(publicResp.getCode())) {
|
||||
JspayResp scanpayResp = publicResp.getObjData();
|
||||
if ("TRADE_SUCCESS".equals(scanpayResp.getState())) {
|
||||
|
||||
payment.setTradeNumber(scanpayResp.getPayOrderId());
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||
|
||||
//处理支付成功的订单
|
||||
orderInfo.setStatus("closed");
|
||||
orderInfo.setPayOrderNo(scanpayResp.getPayOrderId());
|
||||
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
|
||||
//更新购物车状态
|
||||
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
|
||||
log.info("更新购物车:{}", cartCount);
|
||||
|
||||
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
|
||||
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
|
||||
}else {
|
||||
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
|
||||
}
|
||||
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("token", token);
|
||||
// jsonObject.put("type", "create");
|
||||
// jsonObject.put("orderId", orderId);
|
||||
//
|
||||
// producer.putOrderCollect(jsonObject.toJSONString());
|
||||
//
|
||||
// producer.printMechine(orderId);
|
||||
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
return Result.success(CodeEnum.SUCCESS, mapper.readTree(scanpayResp.getPayInfo()));
|
||||
|
||||
}else if("TRADE_AWAIT".equals(scanpayResp.getState())){
|
||||
orderInfo.setStatus("paying");
|
||||
orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
|
||||
payment.setTradeNumber(scanpayResp.getPayOrderId());
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||
|
||||
|
||||
if("WECHAT".equals(scanpayResp.getPayType())){
|
||||
orderInfo.setPayType("WECHAT");
|
||||
}else if("ALIPAY".equals(scanpayResp.getPayType())){
|
||||
orderInfo.setPayType("ALIPAY");
|
||||
}else if("UNIONPAY".equals(scanpayResp.getPayType())){
|
||||
orderInfo.setPayType("UNIONPAY");
|
||||
}
|
||||
|
||||
|
||||
tbOrderInfoMapper.updateByPrimaryKey(orderInfo);
|
||||
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
return Result.success(CodeEnum.PAYING,mapper.readTree(scanpayResp.getPayInfo()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Result.fail(CodeEnum.FAIL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String generateOrderNumber() {
|
||||
String date = DateUtils.getSdfTimes();
|
||||
Random random = new Random();
|
||||
int randomNum = random.nextInt(900) + 100;
|
||||
return "QR" + date + randomNum;
|
||||
}
|
||||
|
||||
|
||||
public Result createOrder(String ip,String userId,String payType,String shopId,BigDecimal amount) throws JsonProcessingException {
|
||||
|
||||
if(ObjectUtil.isNull(userId)||ObjectUtil.isEmpty(userId)||ObjectUtil.isEmpty(payType)||ObjectUtil.isNull(payType)
|
||||
|
||||
||ObjectUtil.isNull(shopId)||ObjectUtil.isEmpty(shopId)||ObjectUtil.isNull(shopId)||ObjectUtil.isNull(amount)||ObjectUtil.isEmpty(amount)
|
||||
){
|
||||
return Result.fail(CodeEnum.PARAM);
|
||||
}
|
||||
|
||||
if(!"WECHAT".equals(payType)||!"ALIPAY".equals(payType)){
|
||||
return Result.fail(CodeEnum.PARAM);
|
||||
}
|
||||
TbShopInfo shopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
|
||||
|
||||
if(ObjectUtil.isNull(shopInfo)){
|
||||
return Result.fail(CodeEnum.SHOPINFONOEXIST);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TbOrderInfo orderInfo=new TbOrderInfo();
|
||||
|
||||
String orderNo = generateOrderNumber();
|
||||
orderInfo.setOrderNo(orderNo);
|
||||
orderInfo.setSettlementAmount(amount);
|
||||
orderInfo.setPackFee(BigDecimal.ZERO);
|
||||
orderInfo.setOriginAmount(amount);
|
||||
orderInfo.setPayAmount(amount);
|
||||
orderInfo.setAmount(amount);
|
||||
orderInfo.setRefundAmount(BigDecimal.ZERO);
|
||||
orderInfo.setPayType(payType);
|
||||
orderInfo.setPayAmount(amount);
|
||||
orderInfo.setOrderAmount(amount);
|
||||
orderInfo.setSendType("QR");
|
||||
orderInfo.setStatus("WAIT_PAY");
|
||||
orderInfo.setMerchantId(shopInfo.getMerchantId());
|
||||
orderInfo.setShopId(shopId);
|
||||
orderInfo.setRefundAble(Byte.valueOf("1"));
|
||||
orderInfo.setSystemTime(System.currentTimeMillis());
|
||||
orderInfo.setCreatedAt(System.currentTimeMillis());
|
||||
orderInfo.setIsAccepted(Byte.valueOf("1"));
|
||||
orderInfo.setTradeDay(DateUtils.getDay());
|
||||
|
||||
tbOrderInfoMapper.insert(orderInfo);
|
||||
|
||||
|
||||
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderInfo.getId().toString());
|
||||
if (ObjectUtil.isEmpty(payment) || payment == null) {
|
||||
payment = new TbOrderPayment();
|
||||
payment.setPayTypeId("ysk");
|
||||
payment.setAmount(orderInfo.getOrderAmount());
|
||||
payment.setPaidAmount(orderInfo.getPayAmount());
|
||||
payment.setHasRefundAmount(BigDecimal.ZERO);
|
||||
payment.setReceived(payment.getAmount());
|
||||
payment.setChangeFee(BigDecimal.ZERO);
|
||||
payment.setMemberId(orderInfo.getMemberId());
|
||||
payment.setShopId(orderInfo.getShopId());
|
||||
payment.setOrderId(orderInfo.getId().toString());
|
||||
payment.setCreatedAt(System.currentTimeMillis());
|
||||
payment.setAuthCode("");
|
||||
tbOrderPaymentMapper.insert(payment);
|
||||
} else {
|
||||
payment.setAuthCode("");
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
tbOrderPaymentMapper.updateByPrimaryKey(payment);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
|
||||
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
||||
return Result.fail(CodeEnum.NOCUSTOMER);
|
||||
}
|
||||
|
||||
String reqbody = "店铺收款码";
|
||||
|
||||
|
||||
PublicResp<JspayResp> publicResp = thirdPayService.jspay(url,thirdApply.getAppId(),thirdApply.getAppToken(),reqbody,reqbody,orderInfo.getOrderAmount().multiply(new BigDecimal(100)).longValue(),payType,"WECHAT".equals(payType)?thirdApply.getSmallAppid():null,userId,ip,DateUtils.getSsdfTimes(),thirdApply.getStoreId(),backUrl,backUrl);
|
||||
|
||||
|
||||
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
||||
if ("000000".equals(publicResp.getCode())) {
|
||||
JspayResp scanpayResp = publicResp.getObjData();
|
||||
if ("TRADE_SUCCESS".equals(scanpayResp.getState())) {
|
||||
|
||||
payment.setTradeNumber(scanpayResp.getPayOrderId());
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||
|
||||
//处理支付成功的订单
|
||||
orderInfo.setStatus("closed");
|
||||
orderInfo.setPayOrderNo(scanpayResp.getPayOrderId());
|
||||
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
return Result.success(CodeEnum.SUCCESS, mapper.readTree(scanpayResp.getPayInfo()));
|
||||
|
||||
} else if ("TRADE_AWAIT".equals(scanpayResp.getState())) {
|
||||
orderInfo.setStatus("paying");
|
||||
orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
|
||||
payment.setTradeNumber(scanpayResp.getPayOrderId());
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||
|
||||
|
||||
if ("WECHAT".equals(scanpayResp.getPayType())) {
|
||||
orderInfo.setPayType("WECHAT");
|
||||
} else if ("ALIPAY".equals(scanpayResp.getPayType())) {
|
||||
orderInfo.setPayType("ALIPAY");
|
||||
} else if ("UNIONPAY".equals(scanpayResp.getPayType())) {
|
||||
orderInfo.setPayType("UNIONPAY");
|
||||
}
|
||||
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
return Result.success(CodeEnum.PAYING, mapper.readTree(scanpayResp.getPayInfo()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.fail(CodeEnum.FAIL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(MD5Util.encrypt("123456".concat("13718478323").concat("10")));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ApppayReq implements Serializable {
|
||||
|
||||
|
||||
private String subject;
|
||||
|
||||
private String body;
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String currency="cny";
|
||||
|
||||
/**
|
||||
* 微信 WECHAT;
|
||||
* 支付宝 ALIPAY
|
||||
*/
|
||||
private String payType;
|
||||
|
||||
private String clientIp;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String notifyUrl;
|
||||
|
||||
private String returnUrl;
|
||||
|
||||
|
||||
public ApppayReq(String subject, String body, Long amount, String currency, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
|
||||
this.subject = subject;
|
||||
this.body = body;
|
||||
this.amount = amount;
|
||||
this.currency = currency;
|
||||
this.payType = payType;
|
||||
this.clientIp = clientIp;
|
||||
this.mchOrderNo = mchOrderNo;
|
||||
this.storeId = storeId;
|
||||
this.notifyUrl = notifyUrl;
|
||||
this.returnUrl = returnUrl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class H5payReq implements Serializable {
|
||||
|
||||
private String subject;
|
||||
|
||||
private String body;
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String currency="cny";
|
||||
|
||||
/**
|
||||
* 微信 WECHAT;
|
||||
* 支付宝 ALIPAY
|
||||
*/
|
||||
private String payType;
|
||||
|
||||
private String clientIp;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String notifyUrl;
|
||||
|
||||
private String returnUrl;
|
||||
|
||||
|
||||
public H5payReq(String subject, String body, Long amount, String currency, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
|
||||
this.subject = subject;
|
||||
this.body = body;
|
||||
this.amount = amount;
|
||||
this.currency = currency;
|
||||
this.payType = payType;
|
||||
this.clientIp = clientIp;
|
||||
this.mchOrderNo = mchOrderNo;
|
||||
this.storeId = storeId;
|
||||
this.notifyUrl = notifyUrl;
|
||||
this.returnUrl = returnUrl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class JspayReq implements Serializable {
|
||||
|
||||
private String subject;
|
||||
|
||||
private String body;
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String currency="cny";
|
||||
|
||||
/**
|
||||
* 微信 WECHAT;
|
||||
* 支付宝 ALIPAY
|
||||
*/
|
||||
private String payType;
|
||||
|
||||
|
||||
private String subAppid;
|
||||
|
||||
private String userId;
|
||||
|
||||
private String clientIp;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String notifyUrl;
|
||||
|
||||
private String returnUrl;
|
||||
|
||||
public JspayReq(String subject, String body, Long amount, String currency, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) {
|
||||
this.subject = subject;
|
||||
this.body = body;
|
||||
this.amount = amount;
|
||||
this.currency = currency;
|
||||
this.payType = payType;
|
||||
this.subAppid = subAppid;
|
||||
this.userId = userId;
|
||||
this.clientIp = clientIp;
|
||||
this.mchOrderNo = mchOrderNo;
|
||||
this.storeId = storeId;
|
||||
this.notifyUrl = notifyUrl;
|
||||
this.returnUrl = returnUrl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ScanpayReq implements Serializable {
|
||||
|
||||
private String subject;
|
||||
|
||||
private String body;
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String currency="cny";
|
||||
|
||||
private String clientIp;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String storeId;
|
||||
|
||||
|
||||
|
||||
public ScanpayReq(String subject, String body, Long amount, String currency, String clientIp, String mchOrderNo, String storeId) {
|
||||
this.subject = subject;
|
||||
this.body = body;
|
||||
this.amount = amount;
|
||||
this.currency = currency;
|
||||
this.clientIp = clientIp;
|
||||
this.mchOrderNo = mchOrderNo;
|
||||
this.storeId = storeId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ApppayResp implements Serializable {
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String payOrderId;
|
||||
|
||||
private String mercNo;
|
||||
|
||||
private String channelSendNo;
|
||||
|
||||
private String channelTradeNo;
|
||||
|
||||
private String state;
|
||||
|
||||
private String payType;
|
||||
|
||||
private String ifCode;
|
||||
|
||||
private String extParam;
|
||||
|
||||
private String payInfo;
|
||||
|
||||
private String liteInfo;
|
||||
|
||||
private String note;
|
||||
|
||||
private String tradeFee;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String subject;
|
||||
|
||||
private String drType;
|
||||
|
||||
private String refundAmt;
|
||||
|
||||
private String refundState;
|
||||
|
||||
private String cashFee;
|
||||
|
||||
private String settlementType;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class H5payResp implements Serializable {
|
||||
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String payOrderId;
|
||||
|
||||
private String mercNo;
|
||||
|
||||
private String channelSendNo;
|
||||
|
||||
private String channelTradeNo;
|
||||
|
||||
private String state;
|
||||
|
||||
private String payType;
|
||||
|
||||
private String ifCode;
|
||||
|
||||
private String extParam;
|
||||
|
||||
private String payInfo;
|
||||
|
||||
private String note;
|
||||
|
||||
private String tradeFee;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String subject;
|
||||
|
||||
private String drType;
|
||||
|
||||
private String refundAmt;
|
||||
|
||||
private String refundState;
|
||||
|
||||
private String cashFee;
|
||||
|
||||
private String settlementType;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class JspayResp implements Serializable {
|
||||
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String payOrderId;
|
||||
|
||||
private String mercNo;
|
||||
|
||||
private String channelSendNo;
|
||||
|
||||
private String channelTradeNo;
|
||||
|
||||
private String state;
|
||||
|
||||
private String payType;
|
||||
|
||||
private String ifCode;
|
||||
|
||||
private String extParam;
|
||||
|
||||
private String payInfo;
|
||||
|
||||
private String note;
|
||||
|
||||
private String tradeFee;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String subject;
|
||||
|
||||
private String drType;
|
||||
|
||||
private String refundAmt;
|
||||
|
||||
private String refundState;
|
||||
|
||||
private String cashFee;
|
||||
|
||||
private String settlementType;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.chaozhanggui.system.cashierservice.thirdpay.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ScanpayResp implements Serializable {
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String payOrderId;
|
||||
|
||||
private String mercNo;
|
||||
|
||||
private String channelSendNo;
|
||||
|
||||
private String channelTradeNo;
|
||||
|
||||
private String state;
|
||||
|
||||
private String payType;
|
||||
|
||||
private String ifCode;
|
||||
|
||||
private String extParam;
|
||||
|
||||
private String payInfo;
|
||||
|
||||
private String note;
|
||||
|
||||
private String tradeFee;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String subject;
|
||||
|
||||
private String drType;
|
||||
|
||||
private String refundAmt;
|
||||
|
||||
private String refundState;
|
||||
|
||||
private String cashFee;
|
||||
|
||||
private String settlementType;
|
||||
}
|
||||
@@ -29,6 +29,13 @@ public class ThirdPayService {
|
||||
|
||||
private static String refund="/api/open/order/refund";
|
||||
|
||||
private static String scanpay="/api/open/payment/scanpay";
|
||||
|
||||
private static String h5pay="/api/open/payment/h5pay";
|
||||
|
||||
private static String jspay="/api/open/payment/jspay";
|
||||
|
||||
private static String apppay="/api/open/payment/apppay";
|
||||
/**
|
||||
* 被扫接口
|
||||
* @param url
|
||||
@@ -47,14 +54,14 @@ public class ThirdPayService {
|
||||
public PublicResp<MainScanResp> mainScan(String url,String appId, String subject, String body, Long amount, String subAppId, String authCode, String orderNo, String storeId, String notifyUrl,
|
||||
String key
|
||||
) {
|
||||
MainScanReq mainScanReq=null;
|
||||
if("66bab943ae82f63b50ae3cff".equals(appId)){
|
||||
|
||||
mainScanReq = new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,1,"TA1824003985261588482",null);
|
||||
url="https://paymentweb.sxczgkj.cn";
|
||||
}else {
|
||||
mainScanReq = new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,0,null,null);
|
||||
}
|
||||
MainScanReq mainScanReq= new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,0,null,null);;
|
||||
// if("66bab943ae82f63b50ae3cff".equals(appId)){
|
||||
//
|
||||
// mainScanReq = new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,1,"TA1824003985261588482",null);
|
||||
// url="https://paymentweb.sxczgkj.cn";
|
||||
// }else {
|
||||
// mainScanReq = new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,0,null,null);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@@ -108,13 +115,13 @@ public class ThirdPayService {
|
||||
|
||||
String clinetIp,String orderNo, String storeId, String notifyUrl,String returnUrl,
|
||||
String key){
|
||||
WxScanPayReq scanPayReq=null;
|
||||
if("66bab943ae82f63b50ae3cff".equals(appId)){
|
||||
scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,1,null,"TA1824003985261588482",notifyUrl,returnUrl);
|
||||
url="https://paymentweb.sxczgkj.cn";
|
||||
}else {
|
||||
scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,0,null,null,notifyUrl,returnUrl);
|
||||
}
|
||||
WxScanPayReq scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,0,null,null,notifyUrl,returnUrl);
|
||||
// if("66bab943ae82f63b50ae3cff".equals(appId)){
|
||||
// scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,1,null,"TA1824003985261588482",notifyUrl,returnUrl);
|
||||
// url="https://paymentweb.sxczgkj.cn";
|
||||
// }else {
|
||||
// scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,0,null,null,notifyUrl,returnUrl);
|
||||
// }
|
||||
|
||||
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(),null,DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
@@ -247,6 +254,177 @@ public class ThirdPayService {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pc 扫码支付
|
||||
* @param url
|
||||
* @param appId
|
||||
* @param key
|
||||
* @param subject
|
||||
* @param body
|
||||
* @param amount
|
||||
* @param clientIp
|
||||
* @param mchOrderNo
|
||||
* @param storeId
|
||||
* @param notifyUrl
|
||||
* @param returnUrl
|
||||
* @return
|
||||
*/
|
||||
public PublicResp<ScanpayResp> pcscanpay(String url,String appId,String key,String subject, String body, Long amount, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl ){
|
||||
ScanpayReq scanpayReq=new ScanpayReq(subject, body, amount, "cny", clientIp, mchOrderNo, storeId);
|
||||
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(),"1.0",String.valueOf(System.currentTimeMillis()));
|
||||
try {
|
||||
String str=JSONUtil.toJSONString(sortFields(scanpayReq));
|
||||
param.setBizData(str);
|
||||
String tt = sortFieldsAndPrint(param);
|
||||
String MD5 = tt.concat("appSecret=" + key);
|
||||
log.info("加签原传:{}", MD5);
|
||||
String sign = MD5Util.encrypt(MD5);
|
||||
param.setSign(sign);
|
||||
String reqbody = JSONUtil.toJSONString(param);
|
||||
log.info("请求参数:{}", reqbody);
|
||||
String response = HttpRequest.post(url.concat(scanpay)).body(reqbody).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
PublicResp<ScanpayResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
||||
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),ScanpayResp.class));
|
||||
return resp;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 手机网页支付
|
||||
* @param url
|
||||
* @param appId
|
||||
* @param key
|
||||
* @param subject
|
||||
* @param body
|
||||
* @param amount
|
||||
* @param payType
|
||||
* @param clientIp
|
||||
* @param mchOrderNo
|
||||
* @param storeId
|
||||
* @param notifyUrl
|
||||
* @param returnUrl
|
||||
* @return
|
||||
*/
|
||||
public PublicResp<H5payResp> h5Pay(String url,String appId,String key,String subject, String body, Long amount, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl){
|
||||
H5payReq h5payReq=new H5payReq(subject, body, amount, "cny", payType, clientIp, mchOrderNo, storeId, notifyUrl, returnUrl);
|
||||
|
||||
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(),"1.0",String.valueOf(System.currentTimeMillis()));
|
||||
try {
|
||||
String str=JSONUtil.toJSONString(sortFields(h5payReq));
|
||||
param.setBizData(str);
|
||||
String tt = sortFieldsAndPrint(param);
|
||||
String MD5 = tt.concat("appSecret=" + key);
|
||||
log.info("加签原传:{}", MD5);
|
||||
String sign = MD5Util.encrypt(MD5);
|
||||
param.setSign(sign);
|
||||
String reqbody = JSONUtil.toJSONString(param);
|
||||
log.info("请求参数:{}", reqbody);
|
||||
String response = HttpRequest.post(url.concat(h5pay)).body(reqbody).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
PublicResp<H5payResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
||||
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),H5payResp.class));
|
||||
return resp;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 公众号/生活号/银联js支付
|
||||
* @param url
|
||||
* @param appId
|
||||
* @param key
|
||||
* @param subject
|
||||
* @param body
|
||||
* @param amount
|
||||
* @param payType
|
||||
* @param subAppid
|
||||
* @param userId
|
||||
* @param clientIp
|
||||
* @param mchOrderNo
|
||||
* @param storeId
|
||||
* @param notifyUrl
|
||||
* @param returnUrl
|
||||
* @return
|
||||
*/
|
||||
public PublicResp<JspayResp> jspay(String url,String appId,String key,String subject, String body, Long amount, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl){
|
||||
JspayReq jspayReq=new JspayReq(subject, body, amount, "cny", payType, subAppid, userId, clientIp, mchOrderNo, storeId, notifyUrl, returnUrl);
|
||||
|
||||
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(),"1.0",String.valueOf(System.currentTimeMillis()));
|
||||
try {
|
||||
String str=JSONUtil.toJSONString(sortFields(jspayReq));
|
||||
param.setBizData(str);
|
||||
String tt = sortFieldsAndPrint(param);
|
||||
String MD5 = tt.concat("appSecret=" + key);
|
||||
log.info("加签原传:{}", MD5);
|
||||
String sign = MD5Util.encrypt(MD5);
|
||||
param.setSign(sign);
|
||||
String reqbody = JSONUtil.toJSONString(param);
|
||||
log.info("请求参数:{}", reqbody);
|
||||
String response = HttpRequest.post(url.concat(jspay)).body(reqbody).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
PublicResp<JspayResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
||||
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),JspayResp.class));
|
||||
return resp;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* app 支付
|
||||
* @param url
|
||||
* @param appId
|
||||
* @param key
|
||||
* @param subject
|
||||
* @param body
|
||||
* @param amount
|
||||
* @param payType
|
||||
* @param clientIp
|
||||
* @param mchOrderNo
|
||||
* @param storeId
|
||||
* @param notifyUrl
|
||||
* @param returnUrl
|
||||
* @return
|
||||
*/
|
||||
|
||||
public PublicResp<ApppayResp> apppay(String url,String appId,String key,String subject, String body, Long amount, String payType, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl){
|
||||
ApppayReq apppayReq=new ApppayReq(subject, body, amount, "cny", payType, clientIp, mchOrderNo, storeId, notifyUrl, returnUrl);
|
||||
|
||||
|
||||
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(), null,DateUtils.getSdfTimes(),"1.0",String.valueOf(System.currentTimeMillis()));
|
||||
try {
|
||||
String str=JSONUtil.toJSONString(sortFields(apppayReq));
|
||||
param.setBizData(str);
|
||||
String tt = sortFieldsAndPrint(param);
|
||||
String MD5 = tt.concat("appSecret=" + key);
|
||||
log.info("加签原传:{}", MD5);
|
||||
String sign = MD5Util.encrypt(MD5);
|
||||
param.setSign(sign);
|
||||
String reqbody = JSONUtil.toJSONString(param);
|
||||
log.info("请求参数:{}", reqbody);
|
||||
String response = HttpRequest.post(url.concat(apppay)).body(reqbody).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
PublicResp<ApppayResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
||||
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),ApppayResp.class));
|
||||
return resp;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -646,7 +646,7 @@ public class RedisUtils {
|
||||
if (database!=0) {
|
||||
jedis.select(database);
|
||||
}
|
||||
Object result = jedis.eval(secKillScript, Arrays.asList( key,num), new ArrayList<>());
|
||||
Object result = jedis.eval(secKillScript, Collections.singletonList( key), Collections.singletonList( num));
|
||||
String reString = String.valueOf(result);
|
||||
return reString;
|
||||
|
||||
@@ -684,4 +684,4 @@ public class RedisUtils {
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,4 +101,23 @@ public class WechatUtil {
|
||||
|
||||
throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
|
||||
}
|
||||
|
||||
|
||||
public static JSONObject getSessionKeyOrOpenId(String code, String appId, String secrete) {
|
||||
String requestUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?";
|
||||
Map<String, String> requestUrlParam = new HashMap<>();
|
||||
// https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN
|
||||
//小程序appId
|
||||
requestUrlParam.put("appid", appId);
|
||||
//小程序secret
|
||||
requestUrlParam.put("secret", secrete);
|
||||
//小程序端返回的code
|
||||
requestUrlParam.put("code", code);
|
||||
//默认参数
|
||||
requestUrlParam.put("grant_type", "authorization_code");
|
||||
//发送post请求读取调用微信接口获取openid用户唯一标识
|
||||
log.info("请求参数:{}",JSONUtil.toJSONString(requestUrlParam));
|
||||
JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doPost(requestUrl,requestUrlParam));
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ import java.util.Map;
|
||||
@Component
|
||||
public class WxAccountUtil {
|
||||
@Value("${wx.ysk.appId}")
|
||||
private static String appId = "wx212769170d2c6b2a";
|
||||
private String appId = "wx212769170d2c6b2a";
|
||||
@Value("${wx.ysk.secrete}")
|
||||
private static String secrete = "8492a7e8d55bbb1b57f5c8276ea1add0";
|
||||
private String secrete = "8492a7e8d55bbb1b57f5c8276ea1add0";
|
||||
@Value("${wx.ysk.warnMsgTmpId}")
|
||||
private static String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0";
|
||||
private String msgTmpId = "C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0";
|
||||
private final TbShopMsgStateMapper shopMsgStateMapper;
|
||||
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
|
||||
|
||||
@@ -49,7 +49,7 @@ public class WxAccountUtil {
|
||||
// sendStockWarnMsg("13213", "31123", "234", "ojC-S6n2DDlpj52iVMoiLL0Ry4HI");
|
||||
}
|
||||
|
||||
public static String getRadarQrCode(Integer shopId) {
|
||||
public String getRadarQrCode(Integer shopId) {
|
||||
HashMap<String, Object> req = new HashMap<>();
|
||||
req.put("expire_seconds", 300);
|
||||
req.put("action_name", "QR_STR_SCENE");
|
||||
@@ -70,7 +70,7 @@ public class WxAccountUtil {
|
||||
}
|
||||
|
||||
|
||||
public static String getAccessToken() {
|
||||
public String getAccessToken() {
|
||||
String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", appId, secrete));
|
||||
JSONObject respInfo = JSONObject.parseObject(resp);
|
||||
if (!respInfo.containsKey("access_token")) {
|
||||
@@ -80,7 +80,7 @@ public class WxAccountUtil {
|
||||
return respInfo.getString("access_token");
|
||||
}
|
||||
|
||||
public static JSONObject sendTemplateMsg(String templateId, String toUserOpenId, Map<String, Object> data) {
|
||||
public JSONObject sendTemplateMsg(String templateId, String toUserOpenId, Map<String, Object> data) {
|
||||
log.info("开始发送微信模板消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data);
|
||||
String accessToken = getAccessToken();
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@ spring:
|
||||
application:
|
||||
name: cashierService
|
||||
datasource:
|
||||
# 内网地址
|
||||
url: jdbc:mysql://rm-bp1kn7h89nz62cno1.mysql.rds.aliyuncs.com:3306/fycashier_pre?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
|
||||
url: jdbc:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_pre?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
|
||||
username: cashier
|
||||
password: Cashier@1@
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
|
||||
@@ -60,6 +60,10 @@ wx:
|
||||
appId: wxd88fffa983758a30
|
||||
secrete: a34a61adc0602118b49400baa8812454
|
||||
warnMsgTmpId: AV-KybUHaK3KtFVLqpy6PHccHBS7XeX__mOM4RbufnQ
|
||||
ali:
|
||||
appId: 2021003175619219
|
||||
privateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCInywsrhhiSNj7jjOB4/zL79pAaLzoYOuOqHeQELxgXrVFmpqJ7y76wniu4nrHKfp4jQVIHw4+IkBsTNwABTPiryVzAQ4ydb/opzn4zblWRB4S7mAgnc2wqO4FMcwSOiHh7uPFAqvB8oZmEizlbXIJSiDFd3rqG2l8ZADjwuwM0nue1fUJLu65d2B6NDFgBIa11enkrNyX9uPiaeIFW62lvTN1W2AUqTJLvfko5ejExGUDkie6g5W5MIvUSKfq7sDkpt5IoQCooBzjJJ/Ckfw/rJlqoPDFzUSiANBABwu0jAJ42MGYdJ8+dyDDUNla20xmMjXbRtUe5roVzJrrgMjFAgMBAAECggEAPKPx9o77sbxF2zod8JxiW57Fj+stVjOWuoZaM27KPjgrW46o42pvvsvMx0stVfNzAkkNvBpUtw167Nccm0Gz6vz0sVwZkhojqT94gs/FYN3xP1PhBPkmEDCbHWEiBEEbQu5G2O47kGV2dB3DIb53bFoju6Ixw3GRW64DmxSss2+ZsErAWPBwbxIbUDGzIxtGhuWrvWX6pSnnvs+PNNqyoisXnh4cDjrmS9qSgsgcL4D0HwNGTsG1uBeLx4g3D2vKKqhP1osEly91P0QAGzcpuvKqeJ2ZwfFMDlabeOyqRQxFW/FLT2DuY1KmBhcGx6tjDMo7EEpVJ7NHcSHYfAa6wQKBgQDzZbIAV7shEiwS6ZwLSbeMvJkWELJtmEGk/qI/01tULHmrwDh8FIjbrHZrQNXruZ+dS+RObahCKywjYVEr/g15v5vv4yA20bmUgmO27/mVj6mpwvoHYBn0H/511a6V7lopFlCA735K+liFZ6ZW+qZxV8gkZ3/ZZDUy1LSArQmg8QKBgQCPsiK+mUdvs+1ReDm09RessbastXgYvj6UWIsPHc4Mxx/6R8qgy9nt2n2u95cK2uONtpNWswpDtOeWVakuHSKHbdG7Xz0DlklHuzin2JhOBwBu36HAVDjWPF+JDcVkUz7hFWFwl0DawRijFBcr0OV6GUoUURB21xtRnrQPmK/lFQKBgHPWFE7hceedVGhz0ZX1sWtDXsAHlkNeUO+LWAB0QGTg/c7lnnw+8ZtKitkkdCrJntMniTJiMc+76De2WwFK2XL14+rY9z3ftiidnYM01l19j8uBRak47WEn0NyXo40rcLFZM1sJn9tjJbnnyFxg0dHjaxcYQtpdPIxCet06fPihAoGAfaqJ3CnsYXH3H4KG5Qxa8fpRCWWCbBEkZVOx+TxVkLMr8hOKz2i3Y93qgHOisimPS8XZwL6/QUsaJU0wsVVldw7Blp3JnDN4TrUa7R7sw4A4Dr6glLSTKDiQTCmw8PYkTXAHURHV8/le9G+DfBwqM8eeE3p5bZTdHVovmlwrp6kCgYEA7uTSOa0phZ7ts++FVdEZf9TI/B4tRuP4aT31BHs9UoCW1g01/NEEBDiHV9udq9B6Cd5onq+QFj4jiwakTNzXjhQZqgmag1TBE9VpahLxYAD5pYn/Tvm8l5vWuSKcOSwQb2lDg5R2/bmCJRV/QHRkdkAAhHGC/TrOskUCRgosUac=
|
||||
publicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQkrz+emAuS1mB3KKDOMmAZRd/BlPbh7fAIHAqAj1+QCZNcV3o2BTLIIqnuKpSlFXDG3uDzp2VsBxcizXuBbFyPGylnD9CgCj5abyh3+FIHPAZ2IM3TtpqImZ0TSPGXrMli4Nir7MvZktgccCqQKCC4o6iaDGz+UwWwJUIPna8fm2tiTZ+KH150CZbKVj4ZGNpBh5XSV/1dRgyQIV9D/EwSbkZ0n6VgKQLJBi0C2UE3QB17aL1Ir6+gDXIDbknN8O7GUD3aMGdThYdSRUb5wp9CZ5qfV7vCS/CgaRo38nhH3NOzkTL+7v0m1ZDHPmqEkn9VzZN6sCQdL7PoAOjHOCwIDAQAB
|
||||
|
||||
|
||||
mybatis-plus:
|
||||
|
||||
Reference in New Issue
Block a user