用户进店信息记录

团购卷卷码排序
团购卷支付
This commit is contained in:
wangw 2024-05-20 15:29:02 +08:00
parent 1aea7ba5ba
commit 1c3908a9ce
5 changed files with 71 additions and 18 deletions

View File

@ -47,7 +47,7 @@ public class GroupOrderInfoController {
*/
@RequestMapping("getCoupon")
public Result queryCouponById(Integer id) {
return Result.success(CodeEnum.SUCCESS,orderCouponService.queryByOrderId(id));
return Result.success(CodeEnum.SUCCESS,orderCouponService.queryNoRefundByOrderId(id));
}
/**

View File

@ -2,8 +2,10 @@ package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.service.ProductService;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -23,16 +25,21 @@ public class ProductController {
/**
* 通过桌码获取shopId
*
* @param code
* @return shopid
*/
@RequestMapping("queryShopIdByTableCode")
public Result queryShopIdByTableCode(@RequestParam("code") String code) {
return productService.queryShopIdByTableCode(code);
public Result queryShopIdByTableCode(@RequestHeader String token, @RequestParam("code") String code) {
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userId = jsonObject.getString("userId");
String openId = jsonObject.getString("openId");
return productService.queryShopIdByTableCode(userId, openId, code);
}
/**
* 通过code和分组Id
*
* @param map
* @return
*/
@ -66,7 +73,7 @@ public class ProductController {
@RequestParam String lat,
@RequestParam String lng,
@RequestHeader String environment) throws Exception {
return productService.productInfo(productId,lat,lng,environment);
return productService.productInfo(productId, lat, lng, environment);
}
/**
@ -76,6 +83,6 @@ public class ProductController {
public Result orderConfirm(
@RequestParam Integer productId,
@RequestHeader String environment) throws Exception {
return productService.orderConfirm(productId,environment);
return productService.orderConfirm(productId, environment);
}
}

View File

@ -22,6 +22,8 @@ import com.chaozhanggui.system.cashierservice.thirdpay.resp.PublicResp;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.WxScanPayResp;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -271,7 +273,7 @@ public class PayService {
}
@Transactional(rollbackFor = Exception.class)
public Result groupOrderPay(String orderId, String payType, String userId, String ip) {
public Result groupOrderPay(String orderId, String payType, String userId, String ip) throws JsonProcessingException {
TbGroupOrderInfo orderInfo = tbGroupOrderInfoMapper.queryById(Integer.valueOf(orderId));
if (!"unpaid".equals(orderInfo.getStatus())) {
@ -370,7 +372,7 @@ public class PayService {
tbProductMapper.upGroupRealSalesNumber(orderInfo.getProId().toString(), orderInfo.getNumber());
return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data"));
} else {
return Result.fail(object.getString("msg"));
return Result.fail("支付失败");
}
}
}else {
@ -381,12 +383,28 @@ public class PayService {
}else {
reqbody=body.toString();
}
PublicResp<WxScanPayResp> publicResp= thirdPayService.scanpay(thirdUrl,thirdApply.getAppId(),reqbody,reqbody,payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(),"WECHAT",thirdApply.getSmallAppid(),userId,ip,orderInfo.getOrderNo(),thirdApply.getStoreId(),callBack,null,thirdApply.getAppToken());
PublicResp<WxScanPayResp> publicResp= thirdPayService.scanpay(
thirdUrl,
thirdApply.getAppId(),
reqbody,
reqbody,
payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(),
"WECHAT",
thirdApply.getSmallAppid(),
userId,
ip,
// orderInfo.getOrderNo(),
DateUtils.getsdfTimesSS(),
thirdApply.getStoreId(),
callBackGroupurl,
null,
thirdApply.getAppToken());
if(ObjectUtil.isNotNull(publicResp)&&ObjectUtil.isNotEmpty(publicResp)){
if("000000".equals(publicResp.getCode())){
WxScanPayResp wxScanPayResp= publicResp.getObjData();
if("TRADE_SUCCESS".equals(wxScanPayResp.getState())){
log.info("团购订单下单结果2{}",wxScanPayResp);
// if("TRADE_SUCCESS".equals(wxScanPayResp.getState())||"TRADE_AWAIT".equals(wxScanPayResp.getState())){
if("TRADE_AWAIT".equals(wxScanPayResp.getState())){
payment.setTradeNumber(wxScanPayResp.getPayOrderId());
payment.setUpdatedAt(System.currentTimeMillis());
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
@ -400,10 +418,13 @@ public class PayService {
jsonObject1.put("data", new JSONArray());
jsonObject1.put("amount", 0);
tbProductMapper.upGroupRealSalesNumber(orderInfo.getProId().toString(), orderInfo.getNumber());
return Result.success(CodeEnum.SUCCESS,wxScanPayResp.getPayInfo());
}else{
return Result.fail(publicResp.getMsg());
ObjectMapper mapper = new ObjectMapper();
return Result.success(CodeEnum.SUCCESS,mapper.readTree(wxScanPayResp.getPayInfo()));
} else{
return Result.fail(wxScanPayResp.getNote());
}
}else {
return Result.fail(publicResp.getMsg());
}
}
}
@ -411,7 +432,7 @@ public class PayService {
}
@Transactional(rollbackFor = Exception.class)
public Result returnOrder(ReturnGroupOrderDto param) {
public Result returngroupOrder(ReturnGroupOrderDto param) {
TbGroupOrderInfo groupOrderInfo = tbGroupOrderInfoMapper.queryById(param.getOrderId());
List<TbGroupOrderCoupon> tbGroupOrderCoupons = orderCouponService.queryNoRefundByOrderId(param.getOrderId());
if (param.getNum() > tbGroupOrderCoupons.size()) {

View File

@ -62,11 +62,35 @@ public class ProductService {
@Autowired
TbProductSkuMapper tbProductSkuMapper;
public Result queryShopIdByTableCode(String code) {
@Autowired
private TbShopUserMapper tbShopUserMapper;
public Result queryShopIdByTableCode(String userId,String openId,String code) {
String shopId = tbShopTableMapper.queryShopIdByTableCode(code);
if (StringUtils.isBlank(shopId)) {
return Result.fail("台桌信息不存在");
}
TbShopUser tbShopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId);
if (ObjectUtil.isEmpty(tbShopUser)) {
tbShopUser = new TbShopUser();
tbShopUser.setAmount(BigDecimal.ZERO);
tbShopUser.setCreditAmount(BigDecimal.ZERO);
tbShopUser.setConsumeAmount(BigDecimal.ZERO);
tbShopUser.setConsumeNumber(0);
tbShopUser.setLevelConsume(BigDecimal.ZERO);
tbShopUser.setStatus(Byte.parseByte("1"));
tbShopUser.setShopId(shopId);
tbShopUser.setUserId(userId);
tbShopUser.setMiniOpenId(openId);
tbShopUser.setIsPwd("1");
tbShopUser.setCreatedAt(System.currentTimeMillis());
tbShopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.insert(tbShopUser);
} else {
tbShopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
}
return Result.success(CodeEnum.SUCCESS, shopId);
}
@ -277,11 +301,11 @@ public class ProductService {
for (TbProductSku tbProductSku : productSku.get()) {
//售价
if (tbProductSku.getSalePrice().compareTo(BigDecimal.ZERO) == 0) {
if(tbProductSku.getOriginPrice().compareTo(BigDecimal.ZERO) == 0){
if (tbProductSku.getOriginPrice().compareTo(BigDecimal.ZERO) == 0) {
productInfo.setOriginPrice(BigDecimal.ZERO);
productInfo.setDiscount(BigDecimal.ZERO);
productInfo.setSalePrice(BigDecimal.ZERO);
}else {
} else {
productInfo.setOriginPrice(tbProductSku.getOriginPrice());
productInfo.setDiscount(BigDecimal.ZERO);
productInfo.setSalePrice(tbProductSku.getOriginPrice());

View File

@ -32,6 +32,7 @@
from tb_group_order_coupon
where order_id = #{orderId}
order by is_refund
</select>
<select id="queryNoRefundByOrderId" resultMap="TbGroupOrderCouponMap">
@ -40,7 +41,7 @@
from tb_group_order_coupon
where order_id = #{orderId}
AND isRefund = 0
AND is_refund = 0
</select>
<!--查询指定行数据-->