Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
c7f68b363e
|
|
@ -1,14 +1,28 @@
|
||||||
package cn.ysk.cashier.controller.product;
|
package cn.ysk.cashier.controller.product;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.ysk.cashier.annotation.AnonymousAccess;
|
import cn.ysk.cashier.annotation.AnonymousAccess;
|
||||||
import cn.ysk.cashier.annotation.Log;
|
import cn.ysk.cashier.annotation.Log;
|
||||||
import cn.ysk.cashier.config.security.security.TokenProvider;
|
import cn.ysk.cashier.config.security.security.TokenProvider;
|
||||||
import cn.ysk.cashier.dto.shoptable.*;
|
import cn.ysk.cashier.dto.shoptable.*;
|
||||||
|
import cn.ysk.cashier.mybatis.mapper.TbMerchantAccountMapper;
|
||||||
|
import cn.ysk.cashier.pojo.TbToken;
|
||||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbMerchantAccount;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbPlussShopStaff;
|
||||||
|
import cn.ysk.cashier.repository.TbTokenRepository;
|
||||||
|
import cn.ysk.cashier.repository.shop.TbPlussShopStaffRepository;
|
||||||
import cn.ysk.cashier.service.product.TbProductService;
|
import cn.ysk.cashier.service.product.TbProductService;
|
||||||
import cn.ysk.cashier.service.shop.TbShopTableService;
|
import cn.ysk.cashier.service.shop.TbShopTableService;
|
||||||
import cn.ysk.cashier.utils.RabbitMsgUtils;
|
import cn.ysk.cashier.utils.RabbitMsgUtils;
|
||||||
|
import cn.ysk.cashier.utils.RedisUtils;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -17,7 +31,9 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/place")
|
@RequestMapping("/api/place")
|
||||||
public class TbPlaceController {
|
public class TbPlaceController {
|
||||||
|
|
@ -25,7 +41,16 @@ public class TbPlaceController {
|
||||||
private final TbProductService tbProductService;
|
private final TbProductService tbProductService;
|
||||||
private final RabbitMsgUtils rabbitMsgUtils;
|
private final RabbitMsgUtils rabbitMsgUtils;
|
||||||
@Resource
|
@Resource
|
||||||
|
private TbPlussShopStaffRepository staffRepository;
|
||||||
|
@Resource
|
||||||
|
private TbMerchantAccountMapper tbMerchantAccountMapper;
|
||||||
|
@Resource
|
||||||
|
private TbTokenRepository tbTokenRepository;
|
||||||
|
@Resource
|
||||||
private TokenProvider tokenProvider;
|
private TokenProvider tokenProvider;
|
||||||
|
@Lazy
|
||||||
|
@Autowired
|
||||||
|
private RedisUtils redisUtils;
|
||||||
|
|
||||||
@GetMapping("/activate")
|
@GetMapping("/activate")
|
||||||
@ApiOperation("查询/product")
|
@ApiOperation("查询/product")
|
||||||
|
|
@ -145,7 +170,17 @@ public class TbPlaceController {
|
||||||
@ApiOperation("代客下单 支付订单")
|
@ApiOperation("代客下单 支付订单")
|
||||||
public ResponseEntity<Object> pay(HttpServletRequest request, @Validated @RequestBody PayDTO payDTO) {
|
public ResponseEntity<Object> pay(HttpServletRequest request, @Validated @RequestBody PayDTO payDTO) {
|
||||||
String token = tokenProvider.getToken(request);
|
String token = tokenProvider.getToken(request);
|
||||||
payDTO.setToken(token);
|
JSONObject userInfo = JSON.parseObject(JSON.toJSONString(redisUtils.get("online-token-"+token)));
|
||||||
|
String userName = userInfo.getString("userName");
|
||||||
|
String shopId = userInfo.getString("shopId");
|
||||||
|
TbPlussShopStaff shopStaff = staffRepository.queryByAccount(userName, shopId);
|
||||||
|
TbMerchantAccount merchantAccount = tbMerchantAccountMapper.selectOne(Wrappers.<TbMerchantAccount>lambdaQuery().eq(TbMerchantAccount::getAccount, shopStaff.getAccount()));
|
||||||
|
Integer accountId = merchantAccount.getId();
|
||||||
|
Integer staffId = shopStaff.getId();
|
||||||
|
List<TbToken> onlineUserList = tbTokenRepository.findListByAccountIdAndStaffId(accountId, staffId);
|
||||||
|
if (CollUtil.isNotEmpty(onlineUserList)) {
|
||||||
|
payDTO.setToken(onlineUserList.get(0).getToken());
|
||||||
|
}
|
||||||
return ResponseEntity.ok(tbShopTableService.pay(payDTO));
|
return ResponseEntity.ok(tbShopTableService.pay(payDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
package cn.ysk.cashier.repository;
|
package cn.ysk.cashier.repository;
|
||||||
|
|
||||||
import javax.persistence.Tuple;
|
|
||||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
|
||||||
import cn.ysk.cashier.pojo.TbToken;
|
import cn.ysk.cashier.pojo.TbToken;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
|
import javax.persistence.Tuple;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -23,7 +22,9 @@ public interface TbTokenRepository extends JpaRepository<TbToken, Integer>, JpaS
|
||||||
Tuple countByAccountId(@Param("shopId") Integer shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
Tuple countByAccountId(@Param("shopId") Integer shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||||
|
|
||||||
@Query(value = "select count(0),DATE_FORMAT(create_time,'%Y-%m-%d')from tb_token where account_id=:shopId " +
|
@Query(value = "select count(0),DATE_FORMAT(create_time,'%Y-%m-%d')from tb_token where account_id=:shopId " +
|
||||||
"and create_time BETWEEN :startTime and :endTime group by DATE_FORMAT( create_time, '%Y-%m-%d') ",nativeQuery = true)
|
"and create_time BETWEEN :startTime and :endTime group by DATE_FORMAT( create_time, '%Y-%m-%d') ", nativeQuery = true)
|
||||||
List<Object[]> countByMonth(@Param("shopId") Integer shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
List<Object[]> countByMonth(@Param("shopId") Integer shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||||
|
|
||||||
|
@Query("from TbToken x where x.accountId=:accountId and x.staffId=:staffId and x.status=1 order by x.id desc")
|
||||||
|
List<TbToken> findListByAccountIdAndStaffId(@Param("accountId") Integer accountId, @Param("staffId") Integer staffId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue