parent
1aea7ba5ba
commit
1c3908a9ce
|
|
@ -47,7 +47,7 @@ public class GroupOrderInfoController {
|
||||||
*/
|
*/
|
||||||
@RequestMapping("getCoupon")
|
@RequestMapping("getCoupon")
|
||||||
public Result queryCouponById(Integer id) {
|
public Result queryCouponById(Integer id) {
|
||||||
return Result.success(CodeEnum.SUCCESS,orderCouponService.queryByOrderId(id));
|
return Result.success(CodeEnum.SUCCESS,orderCouponService.queryNoRefundByOrderId(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@ package com.chaozhanggui.system.cashierservice.controller;
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.chaozhanggui.system.cashierservice.service.ProductService;
|
import com.chaozhanggui.system.cashierservice.service.ProductService;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -23,16 +25,21 @@ public class ProductController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过桌码获取shopId
|
* 通过桌码获取shopId
|
||||||
|
*
|
||||||
* @param code
|
* @param code
|
||||||
* @return shopid
|
* @return shopid
|
||||||
*/
|
*/
|
||||||
@RequestMapping("queryShopIdByTableCode")
|
@RequestMapping("queryShopIdByTableCode")
|
||||||
public Result queryShopIdByTableCode(@RequestParam("code") String code) {
|
public Result queryShopIdByTableCode(@RequestHeader String token, @RequestParam("code") String code) {
|
||||||
return productService.queryShopIdByTableCode(code);
|
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||||
|
String userId = jsonObject.getString("userId");
|
||||||
|
String openId = jsonObject.getString("openId");
|
||||||
|
return productService.queryShopIdByTableCode(userId, openId, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过code和分组Id
|
* 通过code和分组Id
|
||||||
|
*
|
||||||
* @param map
|
* @param map
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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.resp.WxScanPayResp;
|
||||||
import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService;
|
import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService;
|
||||||
import com.chaozhanggui.system.cashierservice.util.*;
|
import com.chaozhanggui.system.cashierservice.util.*;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
@ -271,7 +273,7 @@ public class PayService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@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));
|
TbGroupOrderInfo orderInfo = tbGroupOrderInfoMapper.queryById(Integer.valueOf(orderId));
|
||||||
|
|
||||||
if (!"unpaid".equals(orderInfo.getStatus())) {
|
if (!"unpaid".equals(orderInfo.getStatus())) {
|
||||||
|
|
@ -370,7 +372,7 @@ public class PayService {
|
||||||
tbProductMapper.upGroupRealSalesNumber(orderInfo.getProId().toString(), orderInfo.getNumber());
|
tbProductMapper.upGroupRealSalesNumber(orderInfo.getProId().toString(), orderInfo.getNumber());
|
||||||
return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data"));
|
return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data"));
|
||||||
} else {
|
} else {
|
||||||
return Result.fail(object.getString("msg"));
|
return Result.fail("支付失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
|
|
@ -381,12 +383,28 @@ public class PayService {
|
||||||
}else {
|
}else {
|
||||||
reqbody=body.toString();
|
reqbody=body.toString();
|
||||||
}
|
}
|
||||||
|
PublicResp<WxScanPayResp> publicResp= thirdPayService.scanpay(
|
||||||
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());
|
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(ObjectUtil.isNotNull(publicResp)&&ObjectUtil.isNotEmpty(publicResp)){
|
||||||
if("000000".equals(publicResp.getCode())){
|
if("000000".equals(publicResp.getCode())){
|
||||||
WxScanPayResp wxScanPayResp= publicResp.getObjData();
|
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.setTradeNumber(wxScanPayResp.getPayOrderId());
|
||||||
payment.setUpdatedAt(System.currentTimeMillis());
|
payment.setUpdatedAt(System.currentTimeMillis());
|
||||||
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||||
|
|
@ -400,18 +418,21 @@ public class PayService {
|
||||||
jsonObject1.put("data", new JSONArray());
|
jsonObject1.put("data", new JSONArray());
|
||||||
jsonObject1.put("amount", 0);
|
jsonObject1.put("amount", 0);
|
||||||
tbProductMapper.upGroupRealSalesNumber(orderInfo.getProId().toString(), orderInfo.getNumber());
|
tbProductMapper.upGroupRealSalesNumber(orderInfo.getProId().toString(), orderInfo.getNumber());
|
||||||
return Result.success(CodeEnum.SUCCESS,wxScanPayResp.getPayInfo());
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
return Result.success(CodeEnum.SUCCESS,mapper.readTree(wxScanPayResp.getPayInfo()));
|
||||||
|
} else{
|
||||||
|
return Result.fail(wxScanPayResp.getNote());
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
return Result.fail(publicResp.getMsg());
|
return Result.fail(publicResp.getMsg());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return Result.fail("失败");
|
return Result.fail("失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result returnOrder(ReturnGroupOrderDto param) {
|
public Result returngroupOrder(ReturnGroupOrderDto param) {
|
||||||
TbGroupOrderInfo groupOrderInfo = tbGroupOrderInfoMapper.queryById(param.getOrderId());
|
TbGroupOrderInfo groupOrderInfo = tbGroupOrderInfoMapper.queryById(param.getOrderId());
|
||||||
List<TbGroupOrderCoupon> tbGroupOrderCoupons = orderCouponService.queryNoRefundByOrderId(param.getOrderId());
|
List<TbGroupOrderCoupon> tbGroupOrderCoupons = orderCouponService.queryNoRefundByOrderId(param.getOrderId());
|
||||||
if (param.getNum() > tbGroupOrderCoupons.size()) {
|
if (param.getNum() > tbGroupOrderCoupons.size()) {
|
||||||
|
|
|
||||||
|
|
@ -62,11 +62,35 @@ public class ProductService {
|
||||||
@Autowired
|
@Autowired
|
||||||
TbProductSkuMapper tbProductSkuMapper;
|
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);
|
String shopId = tbShopTableMapper.queryShopIdByTableCode(code);
|
||||||
if (StringUtils.isBlank(shopId)) {
|
if (StringUtils.isBlank(shopId)) {
|
||||||
return Result.fail("台桌信息不存在");
|
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);
|
return Result.success(CodeEnum.SUCCESS, shopId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
from tb_group_order_coupon
|
from tb_group_order_coupon
|
||||||
where order_id = #{orderId}
|
where order_id = #{orderId}
|
||||||
|
order by is_refund
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryNoRefundByOrderId" resultMap="TbGroupOrderCouponMap">
|
<select id="queryNoRefundByOrderId" resultMap="TbGroupOrderCouponMap">
|
||||||
|
|
@ -40,7 +41,7 @@
|
||||||
|
|
||||||
from tb_group_order_coupon
|
from tb_group_order_coupon
|
||||||
where order_id = #{orderId}
|
where order_id = #{orderId}
|
||||||
AND isRefund = 0
|
AND is_refund = 0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!--查询指定行数据-->
|
<!--查询指定行数据-->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue