Merge branch 'test' into dev
# Conflicts: # eladmin-system/src/main/java/cn/ysk/cashier/config/security/config/bean/LoginProperties.java # eladmin-system/src/main/resources/config/application-pre.yml
This commit is contained in:
@@ -36,8 +36,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@EnableAsync
|
||||
@RestController
|
||||
@Api(hidden = true)
|
||||
@SpringBootApplication
|
||||
@EnableTransactionManagement
|
||||
@SpringBootApplication
|
||||
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
|
||||
public class AppRun {
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.ysk.cashier.config;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Configuration//加上这个注解作用,可以被Spring扫描
|
||||
public class RestTemplateConfig {
|
||||
@Bean
|
||||
public RestTemplate restTemplate(ClientHttpRequestFactory factory){
|
||||
return new RestTemplate(factory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
|
||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||
factory.setReadTimeout(500000);//单位为ms
|
||||
factory.setConnectTimeout(500000);//单位为ms
|
||||
return factory;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -108,8 +108,7 @@ public class LoginProperties {
|
||||
@Override
|
||||
protected char[] alphas() {
|
||||
// 生成随机数字和运算符
|
||||
// int n1 = num(1, 10), n2 = num(1, 10);
|
||||
int n1 = num(1, 5), n2 = num(1, 5);
|
||||
int n1 = num(1, 10), n2 = num(1, 10);
|
||||
int opt = num(3);
|
||||
|
||||
// 计算结果
|
||||
|
||||
@@ -43,6 +43,7 @@ import cn.ysk.cashier.config.security.service.dto.JwtUserDto;
|
||||
import cn.ysk.cashier.config.security.service.OnlineUserService;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -232,6 +233,14 @@ public class AuthorizationController {
|
||||
return ResponseEntity.ok(imgResult);
|
||||
}
|
||||
|
||||
@ApiOperation("设置验证码")
|
||||
@AnonymousGetMapping(value = "/setCode")
|
||||
public ResponseEntity<Object> setCode(@RequestParam String uuid, @RequestParam String code) {
|
||||
// 保存
|
||||
redisUtils.set(uuid, code, loginProperties.getLoginCode().getExpiration(), TimeUnit.MINUTES);
|
||||
return ResponseEntity.ok("ok");
|
||||
}
|
||||
|
||||
@ApiOperation("退出登录")
|
||||
@AnonymousDeleteMapping(value = "/logout")
|
||||
public ResponseEntity<Object> logout(HttpServletRequest request) {
|
||||
|
||||
@@ -12,4 +12,29 @@ public interface RedisConstant {
|
||||
public static final String ORDER_MESSAGE="ORDER:MESSAGE:";
|
||||
public static final String ORDER_PRODUCT_NUM = "ORDER_NUM:";
|
||||
public static final String ORDER_CART_EXISTS = "ORDER_CART_EXISTS:";
|
||||
String CURRENT_TABLE_ORDER = "CURRENT_TABLE_ORDER:";
|
||||
|
||||
public static String TABLE_CART = "TABLE:CART:";
|
||||
String ADD_TABLE_CART_LOCK = "ADD_TABLE_CART";
|
||||
String PC_OUT_NUMBER = "PC_OUT_NUMBER:";
|
||||
|
||||
String LOCK_KEY = "LOCK:";
|
||||
String CREATE_ORDER = "CREATE_ORDER";
|
||||
|
||||
|
||||
static String getCurrentOrderKey(String tableId, String shopId) {
|
||||
return CURRENT_TABLE_ORDER + shopId + ":" + tableId;
|
||||
}
|
||||
|
||||
static String getTableCartKey(String tableId, String shopId) {
|
||||
return TABLE_CART + tableId + "-" + shopId;
|
||||
}
|
||||
|
||||
static String getLockKey(String sign, Object... args) {
|
||||
StringBuilder key = new StringBuilder(LOCK_KEY + ":" + sign + ":");
|
||||
for (Object arg : args) {
|
||||
key.append(":").append(arg.toString());
|
||||
}
|
||||
return key.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class TbPayController {
|
||||
public ResponseEntity<?> scanPay(
|
||||
@RequestBody @Validated ScanPayDTO scanPayDTO
|
||||
) {
|
||||
payService.scanPay(scanPayDTO);
|
||||
// payService.scanPay(scanPayDTO);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.controller;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.pojo.TbUserInfo;
|
||||
import cn.ysk.cashier.pojo.shop.TbMerchantAccount;
|
||||
import cn.ysk.cashier.repository.TbUserInfoRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository;
|
||||
import cn.ysk.cashier.service.TbUserInfoService;
|
||||
import cn.ysk.cashier.dto.TbUserInfoQueryCriteria;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2023-11-13
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "/userInfo/list管理")
|
||||
@RequestMapping("/api/tbUserInfo")
|
||||
public class TbUserInfoController {
|
||||
|
||||
private final TbUserInfoService tbUserInfoService;
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('tbUserInfo:list')")
|
||||
public void exportTbUserInfo(HttpServletResponse response, TbUserInfoQueryCriteria criteria) throws IOException {
|
||||
tbUserInfoService.download(tbUserInfoService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询/userInfo/list")
|
||||
public ResponseEntity<Object> queryTbUserInfo(TbUserInfoQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbUserInfoService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("新增/userInfo/list")
|
||||
public ResponseEntity<Object> createTbUserInfo(@Validated @RequestBody TbUserInfo resources){
|
||||
return new ResponseEntity<>(tbUserInfoService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation("修改/userInfo/list")
|
||||
public ResponseEntity<Object> updateTbUserInfo(@Validated @RequestBody TbUserInfo resources){
|
||||
tbUserInfoService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation("删除/userInfo/list")
|
||||
public ResponseEntity<Object> deleteTbUserInfo(@RequestBody Integer[] ids) {
|
||||
tbUserInfoService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
ValidateCodeUtil validateCodeUtil;
|
||||
|
||||
@Autowired
|
||||
RedisUtils redisUtils;
|
||||
|
||||
@GetMapping("sendMsg")
|
||||
public Object sendMsg(){
|
||||
Object o= SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
if(Objects.isNull(o)){
|
||||
throw new BadRequestException("用户登录信息失效");
|
||||
}
|
||||
JSONObject object=JSON.parseObject(JSON.toJSONString(o));
|
||||
if(Objects.isNull(object)){
|
||||
throw new BadRequestException("用户登录信息失效");
|
||||
}
|
||||
String regex="^\\d{11}$";
|
||||
|
||||
if(!object.containsKey("username")||Objects.isNull(object.getString("username"))||
|
||||
!object.getString("username").matches(regex)
|
||||
){
|
||||
throw new BadRequestException("用户登录信息失效");
|
||||
}
|
||||
String phone=object.getString("username");
|
||||
|
||||
String tempcode="SMS_244665149";
|
||||
|
||||
String random = StringUtil.random(6);
|
||||
try {
|
||||
validateCodeUtil.requestValidateCodeAli(phone, random,tempcode);
|
||||
redisUtils.set(phone.concat("#").concat(tempcode),random,300L);
|
||||
return "{\n" +
|
||||
" \"code\": 0,\n" +
|
||||
" \"msg\": \"成功\"\n" +
|
||||
"}";
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
TbMerchantAccountRepository tbMerchantAccountRepository;
|
||||
|
||||
|
||||
@RequestMapping(value = "modfiyUserInfo",method = RequestMethod.POST)
|
||||
public ResponseEntity<Object> modfiyUserInfo(@RequestBody Map<String,String> map){
|
||||
Object o= SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
if(Objects.isNull(o)){
|
||||
throw new BadRequestException("用户登录信息失效");
|
||||
}
|
||||
JSONObject object=JSON.parseObject(JSON.toJSONString(o));
|
||||
if(Objects.isNull(object)){
|
||||
throw new BadRequestException("用户登录信息失效");
|
||||
}
|
||||
String regex="^\\d{11}$";
|
||||
|
||||
if(!object.containsKey("username")||Objects.isNull(object.getString("username"))||
|
||||
!object.getString("username").matches(regex)
|
||||
){
|
||||
throw new BadRequestException("用户登录信息失效");
|
||||
}
|
||||
|
||||
String tempcode="SMS_244665149";
|
||||
String phone=object.getString("username");
|
||||
Object redisCode= redisUtils.get(phone.concat("#").concat(tempcode));
|
||||
if(Objects.isNull(redisCode)){
|
||||
throw new BadRequestException("短信验证码已过期");
|
||||
}
|
||||
|
||||
|
||||
String code= map.get("code");
|
||||
|
||||
if(!redisCode.toString().equals(code)){
|
||||
throw new BadRequestException("短信验证码错误");
|
||||
}
|
||||
redisUtils.del(phone.concat("#").concat(tempcode));
|
||||
String pwd= map.get("pwd");
|
||||
|
||||
TbMerchantAccount account= tbMerchantAccountRepository.findByAccount(phone);
|
||||
if(Objects.isNull(account)){
|
||||
throw new BadRequestException("账户不存在");
|
||||
}
|
||||
|
||||
account.setPwd(MD5Utils.md5(pwd.concat(account.getAccount()).concat(account.getId().toString())));
|
||||
account.setUpdatedAt(System.currentTimeMillis());
|
||||
tbMerchantAccountRepository.save(account);
|
||||
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ public class TbPlaceController {
|
||||
public ResponseEntity<Object> createOrder(
|
||||
@RequestBody CreateOrderDTO createOrderDTO
|
||||
) {
|
||||
return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO, !createOrderDTO.isPostPay()));
|
||||
return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO, !createOrderDTO.isPostPay(), true));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
@@ -188,7 +188,8 @@ public class TbPlaceController {
|
||||
public ResponseEntity<Object> pay(
|
||||
@Validated @RequestBody PayDTO payDTO
|
||||
) {
|
||||
return ResponseEntity.ok(tbShopTableService.pay(payDTO));
|
||||
|
||||
return ResponseEntity.ok(tbShopTableService.pay(payDTO));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
|
||||
@@ -8,6 +8,7 @@ import cn.ysk.cashier.dto.shop.TbShopRechargeListDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.service.TbMShopUserService;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopUserFlowService;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||
import cn.ysk.cashier.service.shop.TbShopUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -37,6 +38,9 @@ public class TbShopUserController {
|
||||
private final TbShopUserService tbShopUserService;
|
||||
private final TbMShopUserService tbMShopUserService;
|
||||
|
||||
private final TbShopUserFlowService tbShopUserFlowService;
|
||||
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
public void exportTbShopUser(HttpServletResponse response, TbShopUserQueryCriteria criteria) throws IOException {
|
||||
@@ -104,4 +108,10 @@ public class TbShopUserController {
|
||||
tbShopUserService.modfiyAccount(map);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("queryShopUserFlow")
|
||||
public ResponseEntity<Object> queryShopUserFlow(@RequestParam("userId") Integer userId,@RequestParam("page") Integer page,@RequestParam("pageSize") Integer pageSize){
|
||||
return new ResponseEntity<>( tbShopUserFlowService.selectByUserId(userId, page, pageSize),HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,5 @@ public class CreateOrderDTO {
|
||||
private String tableId;
|
||||
private String note;
|
||||
private boolean postPay;
|
||||
private Integer orderId;
|
||||
}
|
||||
|
||||
@@ -19,4 +19,5 @@ public class PayDTO {
|
||||
@Max(1)
|
||||
private Double discount;
|
||||
private Integer vipUserId;
|
||||
private String code;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
@@ -12,6 +14,7 @@ import java.io.Serializable;
|
||||
@SuppressWarnings("serial")
|
||||
public class TagProductDepts extends Model<TagProductDepts> {
|
||||
//标签id
|
||||
@TableId(value = "tagId", type = IdType.NONE)
|
||||
private Integer tagId;
|
||||
//商品id
|
||||
private Integer productId;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "tb_activate")
|
||||
public class TbActivate {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id", nullable = false)
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "shop_id")
|
||||
private Integer shopId;
|
||||
|
||||
@Column(name = "min_num")
|
||||
private Integer minNum;
|
||||
|
||||
@Column(name = "max_num")
|
||||
private Integer maxNum;
|
||||
|
||||
@Column(name = "handsel_num", precision = 10, scale = 2)
|
||||
private BigDecimal handselNum;
|
||||
|
||||
@Size(max = 20)
|
||||
@Column(name = "handsel_type", length = 20)
|
||||
private String handselType;
|
||||
|
||||
@Size(max = 20)
|
||||
@Column(name = "is_del", length = 20)
|
||||
private String isDel;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "is_user")
|
||||
private String isUser;
|
||||
|
||||
}
|
||||
@@ -1,39 +1,86 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
* @author admin
|
||||
* @date 2024-09-02
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("tb_shop_user_flow")
|
||||
@Table(name="tb_shop_user_flow")
|
||||
public class TbShopUserFlow extends Model<TbShopUserFlow> {
|
||||
public class TbShopUserFlow implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@ApiModelProperty(value = "id")
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "`shop_user_id`")
|
||||
@ApiModelProperty(value = "shopUserId")
|
||||
private Integer shopUserId;
|
||||
|
||||
@Column(name = "`amount`")
|
||||
@ApiModelProperty(value = "amount")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Column(name = "`balance`")
|
||||
@ApiModelProperty(value = "balance")
|
||||
private BigDecimal balance;
|
||||
|
||||
@Column(name = "`biz_code`")
|
||||
@ApiModelProperty(value = "bizCode")
|
||||
private String bizCode;
|
||||
|
||||
@Column(name = "`biz_name`")
|
||||
@ApiModelProperty(value = "bizName")
|
||||
private String bizName;
|
||||
|
||||
private Date createTime;
|
||||
@Column(name = "`create_time`")
|
||||
@ApiModelProperty(value = "createTime")
|
||||
private Timestamp createTime;
|
||||
|
||||
@Column(name = "`type`")
|
||||
@ApiModelProperty(value = "type")
|
||||
private String type;
|
||||
|
||||
@Column(name = "`is_return`")
|
||||
@ApiModelProperty(value = "是否退款 1 已退款 0 未退款")
|
||||
private String isReturn;
|
||||
|
||||
@Column(name = "`update_time`")
|
||||
@ApiModelProperty(value = "updateTime")
|
||||
private Timestamp updateTime;
|
||||
|
||||
@Column(name = "`remark`")
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
public void copy(TbShopUserFlow source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbOrderPayment;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface MpOrderPaymentMapper extends BaseMapper<TbOrderPayment> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.pojo.TbUserInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface MpUserInfoMapper extends BaseMapper<TbUserInfo> {
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivate;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_activate】的数据库操作Mapper
|
||||
* @createDate 2024-09-03 14:08:30
|
||||
* @Entity cn.ysk.cashier.mybatis.pojo.TbActivatetb
|
||||
*/
|
||||
public interface TbActivateMapper extends BaseMapper<TbActivate> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUser;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@@ -41,4 +42,11 @@ public interface TbShopUserFlowMapper extends BaseMapper<TbShopUserFlow> {
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
|
||||
@Select(value = "select * from tb_shop_user_flow where shop_user_id=#{userId} order by id desc limit #{page},#{size}")
|
||||
List<TbShopUserFlow> selectByUserId(@Param("userId") Integer userId,@Param("page") Integer page,@Param("size") Integer size);
|
||||
|
||||
@Select(value = "select count(0) from tb_shop_user_flow where shop_user_id=#{userId} ")
|
||||
Integer selectCountByUserId(@Param("userId") Integer userId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivate;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_activate】的数据库操作Service
|
||||
* @createDate 2024-09-03 14:08:30
|
||||
*/
|
||||
public interface TbActivateService extends IService<TbActivate> {
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUser;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUserFlow;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
@@ -13,4 +14,9 @@ import java.util.List;
|
||||
public interface TbShopUserFlowService extends IService<TbShopUserFlow> {
|
||||
|
||||
BigDecimal sumUserFlowAmountByConditions(Long shopId, String startTime, String endTime);
|
||||
|
||||
|
||||
IPage<Map<String, Object>> selectByUserId(Integer userId, Integer page, Integer pageSize);
|
||||
|
||||
Integer selectCountByUserId(Integer userId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivate;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateService;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbActivateMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_activate】的数据库操作Service实现
|
||||
* @createDate 2024-09-03 14:08:30
|
||||
*/
|
||||
@Service
|
||||
public class TbActivateServiceImpl extends ServiceImpl<TbActivateMapper, TbActivate>
|
||||
implements TbActivateService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUser;
|
||||
import cn.ysk.cashier.mybatis.service.TbMShopUserService;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbMShopUserMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class TbMShopUserServiceImpl extends ServiceImpl<TbMShopUserMapper, TbShopUser>
|
||||
implements TbMShopUserService{
|
||||
implements TbMShopUserService {
|
||||
|
||||
private final TbMShopUserMapper shopUserMapper;
|
||||
|
||||
|
||||
@@ -3,11 +3,22 @@ package cn.ysk.cashier.mybatis.service.impl;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUserFlow;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbShopUserFlowMapper;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopUserFlowService;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.*;
|
||||
import org.springframework.security.core.parameters.P;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
@@ -18,4 +29,27 @@ public class TbShopUserFlowServiceImpl extends ServiceImpl<TbShopUserFlowMapper,
|
||||
public BigDecimal sumUserFlowAmountByConditions(Long shopId, String startTime, String endTime) {
|
||||
return baseMapper.sumUserFlowAmountByConditions(shopId, startTime, endTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<Map<String, Object>> selectByUserId(Integer userId, Integer page, Integer pageSize) {
|
||||
|
||||
QueryWrapper<TbShopUserFlow> queryWrapper=new QueryWrapper<>();
|
||||
queryWrapper.eq("shop_user_id",userId);
|
||||
|
||||
List<OrderItem> orders=new ArrayList<>();
|
||||
OrderItem orderItem=new OrderItem();
|
||||
orderItem.setColumn("id");
|
||||
orderItem.setAsc(false);
|
||||
orders.add(orderItem);
|
||||
Page page1=new Page<>(page,pageSize);
|
||||
page1.setOrders(orders);
|
||||
return baseMapper.selectMapsPage(page1,queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer selectCountByUserId(Integer userId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.ysk.cashier.mybatis.vo.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Data
|
||||
public class MainScanReq implements Serializable {
|
||||
|
||||
private String subject;
|
||||
|
||||
private String body;
|
||||
|
||||
private Long amount;
|
||||
|
||||
private String subAppid;
|
||||
|
||||
private String currency;
|
||||
|
||||
private String authCode;
|
||||
|
||||
private String mchOrderNo;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String notifyUrl;
|
||||
|
||||
private int divisionMode;
|
||||
|
||||
private ArrayList divList;
|
||||
|
||||
private String divTemplateNo;
|
||||
|
||||
public MainScanReq(String subject, String body, Long amount, String subAppid, String currency, String authCode, String mchOrderNo, String storeId, String notifyUrl, int divisionMode, String divTemplateNo, ArrayList divList) {
|
||||
this.subject = subject;
|
||||
this.body = body;
|
||||
this.amount = amount;
|
||||
this.subAppid = subAppid;
|
||||
this.currency = currency;
|
||||
this.authCode = authCode;
|
||||
this.mchOrderNo = mchOrderNo;
|
||||
this.storeId = storeId;
|
||||
this.notifyUrl = notifyUrl;
|
||||
this.divisionMode=divisionMode;
|
||||
this.divList=divList;
|
||||
this.divTemplateNo=divTemplateNo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package cn.ysk.cashier.mybatis.vo.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class MainScanResp 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 note;
|
||||
|
||||
private String tradeFee;
|
||||
|
||||
private String storeId;
|
||||
|
||||
private String subject;
|
||||
|
||||
private String drType;
|
||||
|
||||
private Long refundAmt;
|
||||
|
||||
private Integer refundState;
|
||||
|
||||
private Long cashFee;
|
||||
|
||||
private String settlementType;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.ysk.cashier.pojo.order;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Table;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class TbFullOrderDetail extends TbOrderDetail{
|
||||
private boolean isPack;
|
||||
private boolean isGift;
|
||||
}
|
||||
@@ -151,6 +151,9 @@ public class TbShopUser implements Serializable {
|
||||
@Column(name = "`mini_open_id`")
|
||||
@ApiModelProperty(value = "小程序openId")
|
||||
private String miniOpenId;
|
||||
@Column(name = "`dynamic_code`")
|
||||
private String dynamicCode;
|
||||
|
||||
|
||||
public void copy(TbShopUser source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.ysk.cashier.repository.order;
|
||||
|
||||
import cn.ysk.cashier.dto.product.StockCountDTO;
|
||||
import cn.ysk.cashier.pojo.order.TbFullOrderDetail;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
import cn.ysk.cashier.vo.TbOrderSaleVO;
|
||||
@@ -36,6 +37,7 @@ public interface TbOrderDetailRepository extends JpaRepository<TbOrderDetail, In
|
||||
@Query("SELECT cart FROM TbOrderDetail cart WHERE cart.orderId = :orderId")
|
||||
List<TbOrderDetail> searchDetailByOrderId(@Param("orderId")Integer orderId);
|
||||
|
||||
|
||||
@Query("SELECT cart FROM TbOrderDetail cart WHERE cart.orderId in :ids")
|
||||
List<TbOrderDetail> searchDetailByOrderIds(@Param("ids")List<Integer> ids);
|
||||
|
||||
|
||||
@@ -4,12 +4,17 @@ import cn.ysk.cashier.dto.ScanPayDTO;
|
||||
import cn.ysk.cashier.dto.shoptable.PayDTO;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
public interface TbPayService {
|
||||
void scanPay(ScanPayDTO scanPayDTO);
|
||||
TbOrderInfo scanPay(PayDTO payDTO);
|
||||
|
||||
TbOrderInfo vipPay(@NotNull Integer shopId, @NotNull Integer orderId, Double discount, Integer vipUserId);
|
||||
|
||||
TbOrderInfo cashPay(PayDTO payDTO);
|
||||
|
||||
TbOrderInfo memberAccountPay(String memberId, String shopId, String accountCode, Integer orderId, Double discount) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,49 +2,68 @@ package cn.ysk.cashier.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.dto.ScanPayDTO;
|
||||
import cn.ysk.cashier.dto.shoptable.PayDTO;
|
||||
import cn.ysk.cashier.enums.TableStateEnum;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUser;
|
||||
import cn.ysk.cashier.mybatis.entity.TbOrderPayment;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUserFlow;
|
||||
import cn.ysk.cashier.mybatis.mapper.*;
|
||||
import cn.ysk.cashier.mybatis.service.TbOrderPaymentService;
|
||||
import cn.ysk.cashier.mybatis.vo.pay.MainScanResp;
|
||||
import cn.ysk.cashier.mybatis.vo.pay.ScanPayReq;
|
||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.pojo.shop.TbMerchantThirdApply;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import cn.ysk.cashier.pojo.shop.*;
|
||||
import cn.ysk.cashier.repository.shop.TbMerchantThirdApplyRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
|
||||
import cn.ysk.cashier.service.TbPayService;
|
||||
import cn.ysk.cashier.utils.RabbitMsgUtils;
|
||||
import cn.ysk.cashier.utils.SnowFlakeUtil;
|
||||
import cn.ysk.cashier.thirdpay.resp.PublicResp;
|
||||
import cn.ysk.cashier.thirdpay.service.ThirdPayService;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TbPayServiceImpl implements TbPayService {
|
||||
|
||||
// @Value("${gateway.url}")
|
||||
// private String gateWayUrl;
|
||||
// @Value("${client.backUrl}")
|
||||
// private String backUrl;
|
||||
// @Value("${thirdPay.payType}")
|
||||
// private String thirdPayType;
|
||||
// @Value("${thirdPay.url}")
|
||||
// private String url;
|
||||
// @Value("${thirdPay.callBack}")
|
||||
// private String callBack;
|
||||
private final TbShopInfoRepository tbShopInfoRepository;
|
||||
private final TbMerchantAccountMapper tbMerchantAccountMapper;
|
||||
private final TbMShopUserMapper tbMShopUserMapper;
|
||||
private final TbShopPayTypeMapper tbShopPayTypeMapper;
|
||||
private final TbMemberInMapper tbMemberInMapper;
|
||||
private final TbActivateMapper tbActivateMapper;
|
||||
@Value("${gateway.url}")
|
||||
private String gateWayUrl;
|
||||
@Value("${client.backUrl}")
|
||||
private String backUrl;
|
||||
@Value("${thirdPay.payType}")
|
||||
private String thirdPayType;
|
||||
@Value("${thirdPay.url}")
|
||||
private String url;
|
||||
@Value("${thirdPay.callBack}")
|
||||
private String callBack;
|
||||
|
||||
|
||||
private final TbOrderInfoMapper orderInfoMapper;
|
||||
private final TbCashierCartMapper cashierCartMapper;
|
||||
@@ -55,10 +74,14 @@ public class TbPayServiceImpl implements TbPayService {
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
private final RabbitMsgUtils rabbitMsgUtils;
|
||||
private final MpShopTableMapper mpShopTableMapper;
|
||||
private final RestTemplate restTemplate;
|
||||
private final MpOrderPaymentMapper mpOrderPaymentMapper;
|
||||
private final ThirdPayService thirdPayService;
|
||||
private final MpUserInfoMapper mpUserInfoMapper;
|
||||
|
||||
|
||||
|
||||
public TbPayServiceImpl(TbOrderInfoMapper orderInfoMapper, TbCashierCartMapper cashierCartMapper, TbMerchantThirdApplyRepository merchantThirdApplyRepository, TbOrderPaymentService orderPaymentService, TbShopPayTypeMapper shopPayTypeMapper, TbOrderDetailMapper orderDetailMapper, RabbitTemplate rabbitTemplate, RabbitMsgUtils rabbitMsgUtils, MpShopTableMapper mpShopTableMapper, TbMShopUserMapper shopUserMapper, TbShopUserFlowMapper shopUserFlowMapper) {
|
||||
public TbPayServiceImpl(TbOrderInfoMapper orderInfoMapper, TbCashierCartMapper cashierCartMapper, TbMerchantThirdApplyRepository merchantThirdApplyRepository, TbOrderPaymentService orderPaymentService, TbShopPayTypeMapper shopPayTypeMapper, TbOrderDetailMapper orderDetailMapper, RabbitTemplate rabbitTemplate, RabbitMsgUtils rabbitMsgUtils, MpShopTableMapper mpShopTableMapper, RestTemplate restTemplate, MpOrderPaymentMapper mpOrderPaymentMapper, ThirdPayService thirdPayService, TbMShopUserMapper shopUserMapper, TbShopUserFlowMapper shopUserFlowMapper, TbShopInfoRepository tbShopInfoRepository, TbMerchantAccountMapper tbMerchantAccountMapper, TbMShopUserMapper tbMShopUserMapper, TbShopPayTypeMapper tbShopPayTypeMapper, TbMemberInMapper tbMemberInMapper, MpUserInfoMapper mpUserInfoMapper, TbActivateMapper tbActivateMapper) {
|
||||
this.orderInfoMapper = orderInfoMapper;
|
||||
this.cashierCartMapper = cashierCartMapper;
|
||||
this.merchantThirdApplyRepository = merchantThirdApplyRepository;
|
||||
@@ -68,12 +91,22 @@ public class TbPayServiceImpl implements TbPayService {
|
||||
this.rabbitTemplate = rabbitTemplate;
|
||||
this.rabbitMsgUtils = rabbitMsgUtils;
|
||||
this.mpShopTableMapper = mpShopTableMapper;
|
||||
this.restTemplate = restTemplate;
|
||||
this.mpOrderPaymentMapper = mpOrderPaymentMapper;
|
||||
this.thirdPayService = thirdPayService;
|
||||
this.shopUserMapper = shopUserMapper;
|
||||
this.shopUserFlowMapper = shopUserFlowMapper;
|
||||
this.tbShopInfoRepository = tbShopInfoRepository;
|
||||
this.tbMerchantAccountMapper = tbMerchantAccountMapper;
|
||||
this.tbMShopUserMapper = tbMShopUserMapper;
|
||||
this.tbShopPayTypeMapper = tbShopPayTypeMapper;
|
||||
this.tbMemberInMapper = tbMemberInMapper;
|
||||
this.mpUserInfoMapper = mpUserInfoMapper;
|
||||
this.tbActivateMapper = tbActivateMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scanPay(ScanPayDTO scanPayDTO) {
|
||||
public TbOrderInfo scanPay(PayDTO scanPayDTO) {
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectOne(new LambdaUpdateWrapper<TbOrderInfo>()
|
||||
.in(TbOrderInfo::getStatus, "unpaid", "paying")
|
||||
.eq(TbOrderInfo::getId, scanPayDTO.getOrderId())
|
||||
@@ -101,6 +134,8 @@ public class TbPayServiceImpl implements TbPayService {
|
||||
body.append(cashierCart.getName());
|
||||
}
|
||||
|
||||
BigDecimal payMount = orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(scanPayDTO.getDiscount())).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
|
||||
TbMerchantThirdApply thirdApply = merchantThirdApplyRepository.getById(Integer.valueOf(orderInfo.getMerchantId()));
|
||||
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
||||
@@ -110,7 +145,7 @@ public class TbPayServiceImpl implements TbPayService {
|
||||
String payType;
|
||||
String payName;
|
||||
String qpay;
|
||||
String payTypeCode = scanPayDTO.getAuthCode().substring(0, 2);// 判断收款码
|
||||
String payTypeCode = scanPayDTO.getCode().substring(0, 2);// 判断收款码
|
||||
|
||||
if(Integer.parseInt(payTypeCode) >=25 && Integer.parseInt(payTypeCode) <= 30){
|
||||
payType = "aliPay";
|
||||
@@ -140,7 +175,7 @@ public class TbPayServiceImpl implements TbPayService {
|
||||
if (ObjectUtil.isEmpty(payment) || payment == null) {
|
||||
payment = new TbOrderPayment();
|
||||
payment.setPayTypeId("ysk");
|
||||
payment.setAmount(orderInfo.getOrderAmount().doubleValue());
|
||||
payment.setAmount(payMount.doubleValue());
|
||||
payment.setPaidAmount(orderInfo.getPayAmount().doubleValue());
|
||||
payment.setHasRefundAmount((double) 0);
|
||||
payment.setPayName(payName);
|
||||
@@ -151,152 +186,146 @@ public class TbPayServiceImpl implements TbPayService {
|
||||
payment.setShopId(orderInfo.getShopId());
|
||||
payment.setOrderId(orderInfo.getId().toString());
|
||||
payment.setCreatedAt(System.currentTimeMillis());
|
||||
payment.setAuthCode(scanPayDTO.getAuthCode());
|
||||
payment.setAuthCode(scanPayDTO.getCode());
|
||||
orderPaymentService.save(payment);
|
||||
} else {
|
||||
payment.setAuthCode(scanPayDTO.getAuthCode());
|
||||
payment.setAuthCode(scanPayDTO.getCode());
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
orderPaymentService.updateById(payment);
|
||||
}
|
||||
|
||||
|
||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||
orderInfo.setPayAmount(payMount);
|
||||
orderInfo.setPayType(qpay);
|
||||
orderInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
orderInfoMapper.update(orderInfo, new LambdaUpdateWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getId, scanPayDTO.getOrderId()));
|
||||
|
||||
// if ("ysk".equals(thirdPayType)) {
|
||||
//
|
||||
// ScanPayReq scanPayReq = new ScanPayReq();
|
||||
// scanPayReq.setAppId(thirdApply.getAppId());
|
||||
// scanPayReq.setTimestamp(System.currentTimeMillis());
|
||||
// scanPayReq.setAuthCode(scanPayDTO.getAuthCode());
|
||||
// scanPayReq.setNotifyUrl(backUrl);
|
||||
// scanPayReq.setConsumeFee(BigDecimal.valueOf(payment.getAmount()).setScale(2, RoundingMode.DOWN).toPlainString());
|
||||
//
|
||||
// Map<String, Object> map = BeanUtil.transBean2Map(scanPayReq);
|
||||
// scanPayReq.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
|
||||
//
|
||||
//
|
||||
// ResponseEntity<String> response = restTemplate.postForEntity(gateWayUrl.concat("merchantOrder/scanPay"), scanPayReq, String.class);
|
||||
// if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
||||
// JSONObject object = JSONObject.parseObject(response.getBody());
|
||||
// if (object.get("code").equals("0")) {
|
||||
// payment.setTradeNumber(object.getJSONObject("data").get("orderNumber").toString());
|
||||
// payment.setUpdatedAt(System.currentTimeMillis());
|
||||
// orderPaymentService.saveOrUpdate(payment);
|
||||
//
|
||||
// //处理支付成功的订单
|
||||
// orderInfo.setStatus("closed");
|
||||
// orderInfo.setPayOrderNo(object.getJSONObject("data").get("orderNumber").toString());
|
||||
// orderInfoMapper.update(orderInfo, new LambdaQueryWrapper<TbOrderInfo>()
|
||||
// .eq(TbOrderInfo::getId, scanPayDTO.getOrderId()));
|
||||
//
|
||||
// //更新购物车状态
|
||||
// TbCashierCart cashierCart = new TbCashierCart();
|
||||
// cashierCart.setStatus("final");
|
||||
// int cartCount = cashierCartMapper.update(cashierCart, new LambdaQueryWrapper<TbCashierCart>()
|
||||
// .eq(TbCashierCart::getOrderId, scanPayDTO.getOrderId()));
|
||||
// log.info("更新购物车:{}", cartCount);
|
||||
//
|
||||
// //更新子单状态
|
||||
// TbOrderDetail orderDetail = new TbOrderDetail();
|
||||
// orderDetail.setStatus("closed");
|
||||
// orderDetailMapper.update(orderDetail, new LambdaQueryWrapper<TbOrderDetail>()
|
||||
// .eq(TbOrderDetail::getOrderId, scanPayDTO.getOrderId()));
|
||||
//
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("type", "create");
|
||||
// jsonObject.put("orderId", scanPayDTO.getOrderId());
|
||||
//
|
||||
// rabbitMsgUtils.sendOrderCollectMsg(jsonObject);
|
||||
//
|
||||
//
|
||||
// producer.printMechine(orderId);
|
||||
//
|
||||
// return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data"));
|
||||
// } else {
|
||||
// String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null;
|
||||
// if (ObjectUtil.isNotNull(status) && "7".equals(status)) {
|
||||
//
|
||||
// orderInfo.setStatus("paying");
|
||||
// orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||
// tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
//
|
||||
// payment.setTradeNumber(object.getJSONObject("data").get("orderNumber").toString());
|
||||
// payment.setUpdatedAt(System.currentTimeMillis());
|
||||
// tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||
// return Result.success(CodeEnum.PAYING);
|
||||
// }
|
||||
//// orderInfo.setStatus("fail");
|
||||
//// orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||
//// tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
//
|
||||
// return Result.fail(object.getString("msg"));
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
//
|
||||
// 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<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), reqbody, reqbody, payment.getAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), payType.equals("wechatPay") ? thirdApply.getSmallAppid() : null, authCode, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
|
||||
// if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
||||
// if ("000000".equals(publicResp.getCode())) {
|
||||
// MainScanResp mainScanResp = publicResp.getObjData();
|
||||
// if ("TRADE_SUCCESS".equals(mainScanResp.getState())) {
|
||||
// payment.setTradeNumber(mainScanResp.getPayOrderId());
|
||||
// payment.setUpdatedAt(System.currentTimeMillis());
|
||||
// tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||
//
|
||||
// //处理支付成功的订单
|
||||
// orderInfo.setStatus("closed");
|
||||
// orderInfo.setPayOrderNo(mainScanResp.getPayOrderId());
|
||||
// tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
//
|
||||
// //更新购物车状态
|
||||
// int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
|
||||
// log.info("更新购物车:{}", cartCount);
|
||||
//
|
||||
// //更新子单状态
|
||||
// tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
|
||||
//
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("token", token);
|
||||
// jsonObject.put("type", "create");
|
||||
// jsonObject.put("orderId", orderId);
|
||||
//
|
||||
// producer.putOrderCollect(jsonObject.toJSONString());
|
||||
//
|
||||
// producer.printMechine(orderId);
|
||||
//
|
||||
// return Result.success(CodeEnum.SUCCESS, mainScanResp);
|
||||
// } else if ("TRADE_AWAIT".equals(mainScanResp.getState())) {
|
||||
// orderInfo.setStatus("paying");
|
||||
// orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||
// tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
//
|
||||
// payment.setTradeNumber(mainScanResp.getPayOrderId());
|
||||
// payment.setUpdatedAt(System.currentTimeMillis());
|
||||
// tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||
// return Result.success(CodeEnum.PAYING);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
if ("ysk".equals(thirdPayType)) {
|
||||
|
||||
ScanPayReq scanPayReq = new ScanPayReq();
|
||||
scanPayReq.setAppId(thirdApply.getAppId());
|
||||
scanPayReq.setTimestamp(System.currentTimeMillis());
|
||||
scanPayReq.setAuthCode(scanPayDTO.getCode());
|
||||
scanPayReq.setNotifyUrl(backUrl);
|
||||
scanPayReq.setConsumeFee(BigDecimal.valueOf(payment.getAmount()).setScale(2, RoundingMode.DOWN).toPlainString());
|
||||
|
||||
Map<String, Object> map = BeanUtil.transBean2Map(scanPayReq);
|
||||
scanPayReq.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
|
||||
|
||||
|
||||
ResponseEntity<String> response = restTemplate.postForEntity(gateWayUrl.concat("merchantOrder/scanPay"), scanPayReq, String.class);
|
||||
log.info("响应信息, {}", response);
|
||||
if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
||||
JSONObject object = JSONObject.parseObject(response.getBody());
|
||||
if (object.get("code").equals("0")) {
|
||||
payment.setTradeNumber(object.getJSONObject("data").get("orderNumber").toString());
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
orderPaymentService.saveOrUpdate(payment);
|
||||
|
||||
//处理支付成功的订单
|
||||
orderInfo.setStatus("closed");
|
||||
orderInfo.setPayOrderNo(object.getJSONObject("data").get("orderNumber").toString());
|
||||
orderInfoMapper.update(orderInfo, new LambdaQueryWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getId, scanPayDTO.getOrderId()));
|
||||
|
||||
//更新购物车状态
|
||||
TbCashierCart cashierCart = new TbCashierCart();
|
||||
cashierCart.setStatus("final");
|
||||
int cartCount = cashierCartMapper.update(cashierCart, new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getOrderId, scanPayDTO.getOrderId()));
|
||||
log.info("更新购物车:{}", cartCount);
|
||||
|
||||
//更新子单状态
|
||||
TbOrderDetail orderDetail = new TbOrderDetail();
|
||||
orderDetail.setStatus("closed");
|
||||
orderDetailMapper.update(orderDetail, new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, scanPayDTO.getOrderId()));
|
||||
|
||||
|
||||
return orderInfo;
|
||||
|
||||
} else {
|
||||
String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null;
|
||||
if (ObjectUtil.isNotNull(status) && "7".equals(status)) {
|
||||
|
||||
orderInfo.setStatus("paying");
|
||||
orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
|
||||
payment.setTradeNumber(object.getJSONObject("data").get("orderNumber").toString());
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
mpOrderPaymentMapper.updateById(payment);
|
||||
|
||||
}
|
||||
// orderInfo.setStatus("fail");
|
||||
// orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||
// tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
return orderInfo;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
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<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(),
|
||||
reqbody, reqbody,
|
||||
BigDecimal.valueOf(payment.getAmount()).setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(),
|
||||
payType.equals("wechatPay") ? thirdApply.getSmallAppid() : null,
|
||||
scanPayDTO.getCode(), DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
|
||||
log.info("响应信息, {}", publicResp);
|
||||
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
||||
if ("000000".equals(publicResp.getCode())) {
|
||||
MainScanResp mainScanResp = publicResp.getObjData();
|
||||
if ("TRADE_SUCCESS".equals(mainScanResp.getState())) {
|
||||
payment.setTradeNumber(mainScanResp.getPayOrderId());
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
orderPaymentService.updateById(payment);
|
||||
|
||||
//处理支付成功的订单
|
||||
orderInfo.setStatus("closed");
|
||||
orderInfo.setPayOrderNo(mainScanResp.getPayOrderId());
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
|
||||
//更新购物车状态
|
||||
int cartCount = cashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getOrderId, orderInfo.getId())
|
||||
.set(TbCashierCart::getStatus, "final"));
|
||||
log.info("更新购物车:{}", cartCount);
|
||||
|
||||
//更新子单状态
|
||||
orderDetailMapper.update(null, new LambdaUpdateWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
|
||||
.set(TbOrderDetail::getStatus, "closed"));
|
||||
|
||||
return orderInfo;
|
||||
} else if ("TRADE_AWAIT".equals(mainScanResp.getState())) {
|
||||
orderInfo.setStatus("paying");
|
||||
orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
|
||||
payment.setTradeNumber(mainScanResp.getPayOrderId());
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
orderPaymentService.updateById(payment);
|
||||
|
||||
return orderInfo;
|
||||
}
|
||||
}
|
||||
|
||||
throw new BadRequestException("支付失败:" + publicResp.getMsg());
|
||||
}
|
||||
|
||||
}
|
||||
throw new BadRequestException("支付失败");
|
||||
|
||||
}
|
||||
|
||||
private final TbMShopUserMapper shopUserMapper;
|
||||
private final TbShopUserFlowMapper shopUserFlowMapper;
|
||||
|
||||
@Override
|
||||
public TbOrderInfo vipPay(@NotNull Integer shopId, @NotNull Integer orderId, Double discount, Integer vipUserId) {
|
||||
|
||||
@@ -314,6 +343,7 @@ public class TbPayServiceImpl implements TbPayService {
|
||||
orderInfo.setUserId(String.valueOf(vipUserId));
|
||||
}
|
||||
|
||||
|
||||
// 扣减会员余额
|
||||
TbShopUser shopUser = shopUserMapper.selectOne(new LambdaUpdateWrapper<TbShopUser>()
|
||||
.eq(TbShopUser::getStatus, 1)
|
||||
@@ -323,32 +353,28 @@ public class TbPayServiceImpl implements TbPayService {
|
||||
throw new BadRequestException("用户不存在或已被禁用");
|
||||
}
|
||||
|
||||
BigDecimal payMount = discount == null ? orderInfo.getOrderAmount() : orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(discount)).setScale(2, RoundingMode.UP);
|
||||
|
||||
long flag = shopUserMapper.decrBalance(Integer.valueOf(orderInfo.getUserId()), payMount);
|
||||
BigDecimal finalAmount = orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(discount)).setScale(2, RoundingMode.HALF_UP);
|
||||
long flag = shopUserMapper.decrBalance(Integer.valueOf(orderInfo.getUserId()), finalAmount);
|
||||
if (flag < 1) {
|
||||
throw new BadRequestException("余额不足或扣除余额失败");
|
||||
}
|
||||
|
||||
TbShopUserFlow userFlow = new TbShopUserFlow();
|
||||
userFlow.setAmount(payMount);
|
||||
userFlow.setBalance(shopUser.getAmount());
|
||||
userFlow.setAmount(finalAmount);
|
||||
userFlow.setBalance(shopUser.getAmount().subtract(finalAmount));
|
||||
userFlow.setShopUserId(shopUser.getId());
|
||||
userFlow.setBizCode("vipCardCash");
|
||||
userFlow.setBizName("余额支付");
|
||||
userFlow.setCreateTime(DateUtil.date());
|
||||
userFlow.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||
userFlow.setType("-");
|
||||
shopUserFlowMapper.insert(userFlow);
|
||||
|
||||
orderInfo.setPayAmount(payMount);
|
||||
if (discount != null && discount != 1) {
|
||||
orderInfo.setDiscountAmount(orderInfo.getOrderAmount().subtract(orderInfo.getPayAmount()));
|
||||
orderInfo.setDiscountRatio(BigDecimal.valueOf(discount));
|
||||
}
|
||||
|
||||
orderInfo.setPayAmount(finalAmount);
|
||||
orderInfo.setPayType("cash");
|
||||
orderInfo.setStatus("closed");
|
||||
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
||||
orderInfo.setDiscountRatio(BigDecimal.valueOf(discount));
|
||||
orderInfo.setDiscountAmount(orderInfo.getAmount().subtract(finalAmount));
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
//更新购物车状态
|
||||
int cartCount = cashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
|
||||
@@ -361,6 +387,11 @@ public class TbPayServiceImpl implements TbPayService {
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
|
||||
private final TbMShopUserMapper shopUserMapper;
|
||||
private final TbShopUserFlowMapper shopUserFlowMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public TbOrderInfo cashPay(PayDTO payDTO) {
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectOne(new LambdaUpdateWrapper<TbOrderInfo>()
|
||||
@@ -384,15 +415,13 @@ public class TbPayServiceImpl implements TbPayService {
|
||||
// return Result.fail(CodeEnum.PAYTYPENOEXIST);
|
||||
// }
|
||||
|
||||
orderInfo.setPayAmount(payDTO.getDiscount() == null ? orderInfo.getOrderAmount() : orderInfo.getOrderAmount()
|
||||
.multiply(BigDecimal.valueOf(payDTO.getDiscount())).setScale(2, RoundingMode.UP));
|
||||
if (payDTO.getDiscount() != null && payDTO.getDiscount() != 1) {
|
||||
orderInfo.setDiscountAmount(orderInfo.getOrderAmount().subtract(orderInfo.getPayAmount()));
|
||||
orderInfo.setDiscountRatio(BigDecimal.valueOf(payDTO.getDiscount()));
|
||||
}
|
||||
BigDecimal payMount = orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(payDTO.getDiscount())).setScale(2, RoundingMode.HALF_UP);
|
||||
orderInfo.setPayAmount(payMount);
|
||||
orderInfo.setPayType("cash");
|
||||
orderInfo.setStatus("closed");
|
||||
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
||||
orderInfo.setDiscountRatio(BigDecimal.valueOf(payDTO.getDiscount()));
|
||||
orderInfo.setDiscountAmount(orderInfo.getAmount().subtract(payMount));
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
|
||||
//更新购物车状态
|
||||
@@ -406,6 +435,99 @@ public class TbPayServiceImpl implements TbPayService {
|
||||
orderDetailMapper.update(orderDetail, new LambdaUpdateWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, payDTO.getOrderId()));
|
||||
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
public TbOrderInfo memberAccountPay(String memberId, String shopId, String accountCode, Integer orderId, Double discount) {
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectOne(new LambdaUpdateWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getId, orderId)
|
||||
.eq(TbOrderInfo::getShopId, shopId));
|
||||
|
||||
if (orderInfo == null) {
|
||||
throw new BadRequestException("订单不存在或已支付");
|
||||
}
|
||||
|
||||
if (!"unpaid".equals(orderInfo.getStatus()) && !"pending".equals(orderInfo.getStatus())) {
|
||||
throw new BadRequestException("此订单不处于未支付状态");
|
||||
}
|
||||
|
||||
BigDecimal payMount = orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(discount)).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
long count = tbShopPayTypeMapper.selectCount(new LambdaQueryWrapper<TbShopPayType>()
|
||||
.eq(TbShopPayType::getShopId, shopId)
|
||||
.eq(TbShopPayType::getIsDisplay, 1)
|
||||
.eq(TbShopPayType::getPayType, "deposit"));
|
||||
if (count < 1) {
|
||||
throw new BadRequestException("未知支付方式");
|
||||
}
|
||||
|
||||
|
||||
TbShopUser user = null;
|
||||
|
||||
if (ObjectUtil.isNotEmpty(memberId)) {
|
||||
user = shopUserMapper.selectById(Integer.valueOf(memberId));
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNotEmpty(accountCode)) {
|
||||
|
||||
if (!accountCode.startsWith("46")) {
|
||||
throw new BadRequestException("无效二维码");
|
||||
}
|
||||
|
||||
user = shopUserMapper.selectOne(new LambdaQueryWrapper<TbShopUser>()
|
||||
.eq(TbShopUser::getShopId, shopId)
|
||||
.eq(TbShopUser::getDynamicCode, accountCode));
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isEmpty(user) || !"1".equals(user.getIsVip().toString())) {
|
||||
throw new BadRequestException("用户不存在");
|
||||
}
|
||||
|
||||
shopUserMapper.update(null, new LambdaUpdateWrapper<TbShopUser>()
|
||||
.eq(TbShopUser::getId, user.getId())
|
||||
.apply(StrUtil.format("amount-{}>=0", payMount.doubleValue()))
|
||||
.setSql(StrUtil.format("amount=amount-{}", payMount.doubleValue()))
|
||||
.setSql(StrUtil.format("consume_amount=consume_amount+{}", payMount.doubleValue()))
|
||||
.setSql(StrUtil.format("consume_number=consume_number+1"))
|
||||
.set(TbShopUser::getUpdatedAt, DateUtil.current() / 1000)
|
||||
);
|
||||
|
||||
|
||||
TbShopUserFlow flow = new TbShopUserFlow();
|
||||
flow.setShopUserId(user.getId());
|
||||
flow.setBizCode("accountPay");
|
||||
flow.setBizName("余额支付");
|
||||
flow.setType("-");
|
||||
flow.setAmount(payMount);
|
||||
flow.setBalance(user.getAmount());
|
||||
flow.setCreateTime(DateUtil.date().toTimestamp());
|
||||
flow.setIsReturn("0");
|
||||
shopUserFlowMapper.insert(flow);
|
||||
|
||||
|
||||
orderInfo.setPayAmount(payMount);
|
||||
orderInfo.setUserId(user.getUserId());
|
||||
orderInfo.setMemberId(user.getId().toString());
|
||||
orderInfo.setPayType("deposit");
|
||||
orderInfo.setStatus("closed");
|
||||
orderInfo.setPayOrderNo("deposit".concat(SnowFlakeUtil.generateOrderNo()));
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
//更新购物车状态
|
||||
int cartCount = cashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getId, orderId)
|
||||
.set(TbCashierCart::getStatus, "final"));
|
||||
|
||||
|
||||
orderDetailMapper.update(null, new LambdaUpdateWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, orderId)
|
||||
.set(TbOrderDetail::getStatus, "closed"));
|
||||
|
||||
log.info("更新购物车:{}", cartCount);
|
||||
|
||||
|
||||
return orderInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class TbVersionServiceImpl implements TbVersionService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAllPage(TbVersionQueryCriteria criteria) {
|
||||
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getPageSize(), Sort.by("createdAt"));
|
||||
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getPageSize(), Sort.by(Sort.Direction.DESC, "createdAt"));
|
||||
Page<TbVersion> page = tbVersionRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
return PageUtil.toPage(page.map(tbVersionMapper::toDto));
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import cn.ysk.cashier.mybatis.service.TbActivateInRecordService;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateOutRecordService;
|
||||
import cn.ysk.cashier.mybatis.service.TbOrderPaymentService;
|
||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
||||
import cn.ysk.cashier.pojo.order.TbFullOrderDetail;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||
|
||||
@@ -153,11 +153,17 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
for (TbProduct product : page.getContent()) {
|
||||
//sku
|
||||
List<TbProductSku> tbProductSkus = tbProductSkuRepository.searchSku(product.getId().toString());
|
||||
|
||||
BigDecimal maxPrice=tbProductSkus.stream().map(TbProductSku::getSalePrice).max(BigDecimal::compareTo).get();
|
||||
log.info("maxPrice:{}",maxPrice);
|
||||
|
||||
List<TbProductSku> skuList = new ArrayList<>();
|
||||
TbProductVo tbProductVo = new TbProductVo();
|
||||
//sku,并且计算销量以及库存
|
||||
double stockNumber = 0.00;
|
||||
|
||||
tbProductVo.setMaxPrice(maxPrice);
|
||||
|
||||
if (product.getIsDistribute() == 1) {
|
||||
stockNumber = product.getStockNumber() == null ? 0 : product.getStockNumber();
|
||||
TbProductSku tbProductSku = null;
|
||||
|
||||
@@ -44,6 +44,7 @@ import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
|
||||
import cn.ysk.cashier.service.impl.TbPayServiceImpl;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
import cn.ysk.cashier.vo.PendingCountVO;
|
||||
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;
|
||||
@@ -70,6 +71,7 @@ import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
@@ -110,6 +112,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
private final String QRCODE = "https://kysh.sxczgkj.cn/codeplate?code=";
|
||||
private final RabbitMsgUtils rabbitMsgUtils;
|
||||
private final TbPayServiceImpl tbPayServiceImpl;
|
||||
private final TbCashierCartMapper tbCashierCartMapper;
|
||||
private final TbOrderDetailMapper tbOrderDetailMapper;
|
||||
private final StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(TbShopTableQueryCriteria criteria, Pageable pageable) {
|
||||
@@ -136,6 +141,25 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
List<TbShopTable> tbShopTableList = tbShopTableRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder));
|
||||
ArrayList<Map<String, Object>> infoList = new ArrayList<>();
|
||||
for (TbShopTable date : tbShopTableList) {
|
||||
String orderId = redisTemplate.opsForValue().get(RedisConstant.CURRENT_TABLE_ORDER + date.getShopId() + ":" + date.getQrcode());
|
||||
if (StrUtil.isBlank(date.getQrcode())) {
|
||||
date.setStatus("closed");
|
||||
} else if (tbCashierCartMapper.selectCount(new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, date.getShopId())
|
||||
.eq(TbCashierCart::getTableId, date.getQrcode())
|
||||
.eq(TbCashierCart::getTradeDay, cn.ysk.cashier.utils.DateUtils.getDay())
|
||||
.eq(TbCashierCart::getStatus, "create")) < 1 || (orderId != null &&
|
||||
tbOrderDetailMapper.selectCount(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getShopId, date.getShopId())
|
||||
.eq(TbOrderDetail::getStatus, "unpaid")
|
||||
.ge(TbOrderDetail::getCreateTime, DateUtil.beginOfDay(new Date()))
|
||||
.eq(TbOrderDetail::getOrderId, orderId)) < 1)
|
||||
) {
|
||||
date.setStatus("idle");
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, date.getQrcode())
|
||||
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
|
||||
}
|
||||
Map<String, Object> itemMap = BeanUtil.beanToMap(date, false, false);
|
||||
if (!"".equals(date.getQrcode())) {
|
||||
itemMap.put("qrcode", QRCODE + date.getQrcode().trim());
|
||||
@@ -320,6 +344,13 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
.eq(TbCashierCart::getSkuId, addCartDTO.getSkuId())
|
||||
.eq(TbCashierCart::getProductId, addCartDTO.getProductId())
|
||||
.eq(TbCashierCart::getTableId, addCartDTO.getTableId())
|
||||
.in(TbCashierCart::getStatus, "create", "refund")
|
||||
// .and(q -> {
|
||||
// q.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
|
||||
// .or()
|
||||
// .isNull(TbCashierCart::getTradeDay);
|
||||
//
|
||||
// });
|
||||
.and(query2 -> {
|
||||
query2.and(query3 -> {
|
||||
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
|
||||
@@ -336,6 +367,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
}
|
||||
|
||||
TbCashierCart tbCashierCart = cashierCartMapper.selectOne(query);
|
||||
// 增加redis购物车数据
|
||||
String tableCartKey = RedisConstant.getTableCartKey(addCartDTO.getTableId(), addCartDTO.getShopId().toString());
|
||||
String tableCart = redisTemplate.opsForValue().get(tableCartKey);
|
||||
// 首次加入
|
||||
if (tbCashierCart == null) {
|
||||
tbCashierCart = new TbCashierCart();
|
||||
@@ -371,6 +405,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
tbCashierCart.setNumber(addCartDTO.getNum());
|
||||
tbCashierCart.setCategoryId(product.getCategoryId());
|
||||
cashierCartRepository.save(tbCashierCart);
|
||||
|
||||
} else {
|
||||
tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice()));
|
||||
|
||||
@@ -399,9 +434,36 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
cashierCartRepository.save(tbCashierCart);
|
||||
}
|
||||
|
||||
setRedisTableCartInfo(addCartDTO.getTableId(), addCartDTO.getShopId().toString(), Collections.singletonList(tbCashierCart), true);
|
||||
|
||||
return tbCashierCart;
|
||||
}
|
||||
|
||||
private void setRedisTableCartInfo(String tableId, String shopId, List<TbCashierCart> tbCashierCartList, boolean isAdd) {
|
||||
String tableCartKey = RedisConstant.getTableCartKey(tableId, shopId);
|
||||
String tableCart = redisTemplate.opsForValue().get(tableCartKey);
|
||||
|
||||
List<TbCashierCart> cartArrayList = new ArrayList<>();
|
||||
if (tableCart != null) {
|
||||
cartArrayList = JSONObject.parseArray(tableCart, TbCashierCart.class);
|
||||
}
|
||||
|
||||
for (TbCashierCart cashierCart : tbCashierCartList) {
|
||||
cartArrayList = cartArrayList.stream().filter(d -> !d.getId().equals(cashierCart.getId())).collect(Collectors.toList());
|
||||
if (isAdd) {
|
||||
cartArrayList.add(cashierCart);
|
||||
}
|
||||
}
|
||||
|
||||
List<TbCashierCart> finalCartArrayList = cartArrayList;
|
||||
Utils.runFunAndCheckKey(() -> {
|
||||
redisTemplate.opsForValue().set(tableCartKey,
|
||||
JSONObject.toJSONString(finalCartArrayList));
|
||||
return null;
|
||||
}, redisTemplate, RedisConstant.ADD_TABLE_CART_LOCK);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeCart(RemoveCartDTO removeCartDTO) {
|
||||
// 会员点单
|
||||
@@ -414,25 +476,64 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
|
||||
if (cashierCart.getOrderId() != null) {
|
||||
orderDetailMapper.delete(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getShopId, cashierCart.getShopId())
|
||||
.eq(TbOrderDetail::getProductId, cashierCart.getProductId())
|
||||
.eq(TbOrderDetail::getProductSkuId, cashierCart.getSkuId())
|
||||
.eq(TbOrderDetail::getOrderId, cashierCart.getOrderId()));
|
||||
}
|
||||
cashierCartMapper.delete(new LambdaQueryWrapper<TbCashierCart>().eq(TbCashierCart::getShopId, removeCartDTO.getShopId())
|
||||
.eq(TbCashierCart::getId, removeCartDTO.getCartId()));
|
||||
|
||||
|
||||
// 清空购物车 出票
|
||||
long carCount = countCar(cashierCart.getTableId(), cashierCart.getShopId(), cashierCart.getMasterId());
|
||||
|
||||
log.info("购物车数量: {}", carCount);
|
||||
if (cashierCart.getOrderId() != null && carCount < 1) {
|
||||
rabbitMsgUtils.printTicket(String.valueOf(cashierCart.getOrderId()));
|
||||
}
|
||||
|
||||
setRedisTableCartInfo(removeCartDTO.getTableId().toString(), removeCartDTO.getShopId().toString(), Collections.singletonList(cashierCart), false);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCart(ClearCartDTO clearCartDTO) {
|
||||
if (clearCartDTO.getVipUserId() != null) {
|
||||
cashierCartMapper.delete(new LambdaQueryWrapper<TbCashierCart>().eq(TbCashierCart::getShopId, clearCartDTO.getShopId())
|
||||
.eq(TbCashierCart::getTableId, clearCartDTO.getTableId())
|
||||
.eq(TbCashierCart::getUserId, clearCartDTO.getVipUserId()));
|
||||
} else {
|
||||
cashierCartMapper.delete(new LambdaQueryWrapper<TbCashierCart>().eq(TbCashierCart::getShopId, clearCartDTO.getShopId())
|
||||
.eq(TbCashierCart::getTableId, clearCartDTO.getTableId())
|
||||
.eq(TbCashierCart::getMasterId, clearCartDTO.getMasterId())
|
||||
.isNull(TbCashierCart::getUserId));
|
||||
String orderId = redisTemplate.opsForValue().get(RedisConstant.getCurrentOrderKey(clearCartDTO.getTableId().toString(), clearCartDTO.getShopId()));
|
||||
|
||||
cashierCartMapper.delete(new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, clearCartDTO.getShopId())
|
||||
.eq(TbCashierCart::getTableId, clearCartDTO.getTableId())
|
||||
.and(q -> {
|
||||
q.eq(TbCashierCart::getMasterId, clearCartDTO.getMasterId())
|
||||
.or()
|
||||
.isNull(TbCashierCart::getMasterId)
|
||||
.or()
|
||||
.eq(TbCashierCart::getMasterId, "");
|
||||
})
|
||||
.and(q -> {
|
||||
q.eq(TbCashierCart::getOrderId, orderId)
|
||||
.or()
|
||||
.isNull(TbCashierCart::getOrderId);
|
||||
})
|
||||
);
|
||||
|
||||
// tbShopTableRepository.deleteByTableIdAndShopId(clearCartDTO.getTableId(), clearCartDTO.getShopId());
|
||||
|
||||
if (StrUtil.isNotBlank(orderId)) {
|
||||
orderDetailMapper.delete(new LambdaQueryWrapper<TbOrderDetail>().eq(TbOrderDetail::getShopId, clearCartDTO.getShopId())
|
||||
.eq(TbOrderDetail::getOrderId, orderId));
|
||||
rabbitMsgUtils.printTicket(orderId);
|
||||
}
|
||||
tbShopTableRepository.deleteByTableIdAndShopId(clearCartDTO.getTableId(), clearCartDTO.getShopId());
|
||||
|
||||
}
|
||||
|
||||
private long countCar(Long tableId, String shopId, String masterId) {
|
||||
String orderId = redisTemplate.opsForValue().get(RedisConstant.getCurrentOrderKey(tableId.toString(), shopId));
|
||||
return tbOrderDetailMapper.selectCount(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getShopId, shopId)
|
||||
.eq(TbOrderDetail::getStatus, "unpaid")
|
||||
.eq(TbOrderDetail::getOrderId, orderId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -449,7 +550,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
})
|
||||
.or((query4 -> {
|
||||
query4.isNull(TbCashierCart::getTradeDay)
|
||||
.eq(TbCashierCart::getMasterId, "");
|
||||
.isNull(TbCashierCart::getMasterId);
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -756,191 +857,232 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
private void getOutNumber(String shopId, String tableId) {
|
||||
String shopKey = RedisConstant.PC_OUT_NUMBER + ":" + shopId;
|
||||
String outNumber = redisTemplate.opsForValue().get(shopKey);
|
||||
if (outNumber == null) {
|
||||
Boolean flag = redisTemplate.opsForValue().setIfAbsent(shopKey, "1");
|
||||
if (flag != null && flag.equals(Boolean.FALSE)) {
|
||||
outNumber = redisTemplate.opsForValue().get(shopKey);
|
||||
}
|
||||
}
|
||||
|
||||
String shopTableKey = RedisConstant.PC_OUT_NUMBER + ":" + shopId;
|
||||
redisTemplate.opsForValue().get(shopTableKey);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TbOrderInfo createOrder(CreateOrderDTO createOrderDTO, boolean addMaterId) {
|
||||
public TbOrderInfo createOrder(CreateOrderDTO createOrderDTO, boolean addMaterId, boolean isPrint) {
|
||||
return Utils.runFunAndCheckKey(() -> {
|
||||
String currentOrderKey = RedisConstant.getCurrentOrderKey(createOrderDTO.getTableId(),
|
||||
createOrderDTO.getShopId().toString());
|
||||
String orderIdValue = redisTemplate.opsForValue().get(currentOrderKey);
|
||||
Integer orderId = orderIdValue == null ? null : Integer.parseInt(orderIdValue);
|
||||
orderId = createOrderDTO.getOrderId() != null ? createOrderDTO.getOrderId() : orderId;
|
||||
|
||||
String day = DateUtils.getDay();
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, createOrderDTO.getShopId())
|
||||
.eq(TbCashierCart::getTableId, createOrderDTO.getTableId())
|
||||
.in(TbCashierCart::getStatus, "create", "refund")
|
||||
.and(query2 -> {
|
||||
query2.or(query3 -> {
|
||||
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
|
||||
.eq(TbCashierCart::getMasterId, createOrderDTO.getMasterId());
|
||||
})
|
||||
.or((query4 -> {
|
||||
query4.isNull(TbCashierCart::getTradeDay)
|
||||
.eq(TbCashierCart::getMasterId, "");
|
||||
}));
|
||||
});
|
||||
String day = DateUtils.getDay();
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, createOrderDTO.getShopId())
|
||||
.eq(TbCashierCart::getTableId, createOrderDTO.getTableId())
|
||||
.in(TbCashierCart::getStatus, "create", "refund")
|
||||
.and(query2 -> {
|
||||
query2.or(query3 -> {
|
||||
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
|
||||
.eq(TbCashierCart::getMasterId, createOrderDTO.getMasterId());
|
||||
})
|
||||
.or((query4 -> {
|
||||
query4.isNull(TbCashierCart::getTradeDay)
|
||||
.isNull(TbCashierCart::getMasterId);
|
||||
}));
|
||||
});
|
||||
// if (createOrderDTO.getVipUserId() != null) {
|
||||
// queryWrapper.eq(TbCashierCart::getUserId, createOrderDTO.getVipUserId());
|
||||
// }else {
|
||||
// queryWrapper.eq(TbCashierCart::getMasterId, createOrderDTO.getMasterId())
|
||||
// .isNull(TbCashierCart::getUserId);
|
||||
// }
|
||||
List<TbCashierCart> cashierCarts = cashierCartMapper
|
||||
.selectList(queryWrapper);
|
||||
if (cashierCarts.isEmpty()) {
|
||||
throw new BadRequestException("购物车为空,请先添加商品");
|
||||
}
|
||||
|
||||
TbShopTable tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
|
||||
.in(TbShopTable::getStatus, "idle", "using"));
|
||||
|
||||
if (tbShopTable == null) {
|
||||
throw new BadRequestException("台桌未开台或不存在");
|
||||
}
|
||||
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
BigDecimal packAMount = BigDecimal.ZERO;
|
||||
BigDecimal feeAmount = BigDecimal.ZERO;
|
||||
BigDecimal saleAmount = BigDecimal.ZERO;
|
||||
List<TbOrderDetail> orderDetails = new ArrayList<>();
|
||||
Integer orderId = null;
|
||||
for (TbCashierCart cashierCart : cashierCarts) {
|
||||
totalAmount = totalAmount.add(cashierCart.getTotalAmount());
|
||||
packAMount = packAMount.add(cashierCart.getPackFee());
|
||||
feeAmount = cashierCart.getPackFee();
|
||||
TbProductSku productSku = productSkuRepository.findById(Integer.valueOf(cashierCart.getSkuId())).orElse(null);
|
||||
TbOrderDetail orderDetail = new TbOrderDetail();
|
||||
|
||||
if (Objects.nonNull(productSku)) {
|
||||
saleAmount = saleAmount.add(productSku.getSalePrice());
|
||||
orderDetail.setProductSkuName(productSku.getSpecSnap());
|
||||
List<TbCashierCart> cashierCarts = cashierCartMapper
|
||||
.selectList(queryWrapper);
|
||||
if (cashierCarts.isEmpty()) {
|
||||
throw new BadRequestException("购物车为空,请先添加商品");
|
||||
}
|
||||
|
||||
orderDetail.setCreateTime(DateUtil.date().toTimestamp());
|
||||
orderDetail.setNum(cashierCart.getNumber());
|
||||
orderDetail.setPrice(cashierCart.getSalePrice());
|
||||
orderDetail.setPriceAmount(cashierCart.getTotalAmount());
|
||||
orderDetail.setProductId(Integer.valueOf(cashierCart.getProductId()));
|
||||
orderDetail.setProductSkuId(Integer.valueOf(cashierCart.getSkuId()));
|
||||
orderDetail.setProductName(cashierCart.getName());
|
||||
orderDetail.setShopId(Integer.valueOf(cashierCart.getShopId()));
|
||||
orderDetail.setPackAmount(cashierCart.getPackFee());
|
||||
orderDetail.setStatus("unpaid");
|
||||
orderDetail.setProductImg(cashierCart.getCoverImg());
|
||||
orderDetails.add(orderDetail);
|
||||
if (cashierCart.getOrderId() != null) {
|
||||
orderId = cashierCart.getOrderId();
|
||||
TbShopTable tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
|
||||
.in(TbShopTable::getStatus, "idle", "using"));
|
||||
|
||||
if (tbShopTable == null) {
|
||||
throw new BadRequestException("台桌未开台或不存在");
|
||||
}
|
||||
}
|
||||
|
||||
TbOrderInfo orderInfo = null;
|
||||
if (orderId != null) {
|
||||
orderInfo = orderInfoMapper.selectById(orderId);
|
||||
}
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
BigDecimal packAMount = BigDecimal.ZERO;
|
||||
BigDecimal feeAmount = BigDecimal.ZERO;
|
||||
BigDecimal saleAmount = BigDecimal.ZERO;
|
||||
List<TbOrderDetail> orderDetails = new ArrayList<>();
|
||||
|
||||
// 修改订单信息
|
||||
if (orderInfo != null) {
|
||||
// 删除历史订单
|
||||
// 更新取餐号
|
||||
orderInfo.setOutNumber(updateOutNumber(String.valueOf(createOrderDTO.getShopId())).toString());
|
||||
orderDetailMapper.delete(new LambdaQueryWrapper<TbOrderDetail>().eq(TbOrderDetail::getOrderId, orderId));
|
||||
orderInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
orderInfo.setSettlementAmount(totalAmount);
|
||||
orderInfo.setAmount(totalAmount);
|
||||
orderInfo.setOriginAmount(totalAmount);
|
||||
for (TbCashierCart cashierCart : cashierCarts) {
|
||||
totalAmount = totalAmount.add(cashierCart.getTotalAmount());
|
||||
packAMount = packAMount.add(cashierCart.getPackFee());
|
||||
feeAmount = cashierCart.getPackFee();
|
||||
TbProductSku productSku = productSkuRepository.findById(Integer.valueOf(cashierCart.getSkuId())).orElse(null);
|
||||
TbOrderDetail orderDetail = new TbOrderDetail();
|
||||
|
||||
if (Objects.nonNull(productSku)) {
|
||||
saleAmount = saleAmount.add(productSku.getSalePrice());
|
||||
orderDetail.setProductSkuName(productSku.getSpecSnap());
|
||||
}
|
||||
|
||||
orderDetail.setCreateTime(DateUtil.date().toTimestamp());
|
||||
orderDetail.setNum(cashierCart.getNumber());
|
||||
orderDetail.setPrice(cashierCart.getSalePrice());
|
||||
orderDetail.setPriceAmount(cashierCart.getTotalAmount());
|
||||
orderDetail.setProductId(Integer.valueOf(cashierCart.getProductId()));
|
||||
orderDetail.setProductSkuId(Integer.valueOf(cashierCart.getSkuId()));
|
||||
orderDetail.setProductName(cashierCart.getName());
|
||||
orderDetail.setShopId(Integer.valueOf(cashierCart.getShopId()));
|
||||
orderDetail.setPackAmount(cashierCart.getPackFee());
|
||||
orderDetail.setStatus("unpaid");
|
||||
orderDetail.setProductImg(cashierCart.getCoverImg());
|
||||
orderDetails.add(orderDetail);
|
||||
if (cashierCart.getOrderId() != null) {
|
||||
orderId = cashierCart.getOrderId();
|
||||
}
|
||||
orderDetail.setOrderId(orderId);
|
||||
}
|
||||
|
||||
TbOrderInfo orderInfo = null;
|
||||
if (orderId != null) {
|
||||
orderInfo = orderInfoMapper.selectById(orderId);
|
||||
|
||||
if (orderInfo == null || !"unpaid".equals(orderInfo.getStatus())) {
|
||||
redisTemplate.delete(currentOrderKey);
|
||||
}
|
||||
}
|
||||
|
||||
// 修改订单信息
|
||||
if (orderInfo != null) {
|
||||
// 删除历史订单
|
||||
// 更新取餐号
|
||||
orderInfo.setOutNumber(updateOutNumber(String.valueOf(createOrderDTO.getShopId())).toString());
|
||||
orderDetailMapper.delete(new LambdaQueryWrapper<TbOrderDetail>().eq(TbOrderDetail::getOrderId, orderId));
|
||||
orderInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
orderInfo.setSettlementAmount(totalAmount);
|
||||
orderInfo.setAmount(totalAmount);
|
||||
orderInfo.setOriginAmount(totalAmount);
|
||||
// orderInfo.setStatus("unpaid");
|
||||
orderInfo.setOrderAmount(totalAmount);
|
||||
orderInfo.setRemark(createOrderDTO.getNote());
|
||||
orderInfo.setFreightAmount(feeAmount);
|
||||
orderInfo.setProductAmount(saleAmount);
|
||||
orderInfo.setTradeDay(DateUtils.getDay());
|
||||
orderInfo.setUseType(createOrderDTO.isPostPay() ? "postPay" : "afterPay");
|
||||
orderInfo.setUserId(createOrderDTO.getVipUserId() == null ? null : String.valueOf(createOrderDTO.getVipUserId()));
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
} else {
|
||||
String orderNo = generateOrderNumber();
|
||||
orderInfo = new TbOrderInfo();
|
||||
orderInfo.setOrderNo(orderNo);
|
||||
orderInfo.setUseType(createOrderDTO.isPostPay() ? "postPay" : "afterPay");
|
||||
orderInfo.setAmount(totalAmount);
|
||||
orderInfo.setPackFee(packAMount);
|
||||
orderInfo.setSettlementAmount(totalAmount);
|
||||
orderInfo.setOriginAmount(totalAmount);
|
||||
orderInfo.setProductAmount(saleAmount);
|
||||
orderInfo.setOrderAmount(totalAmount);
|
||||
orderInfo.setFreightAmount(feeAmount);
|
||||
orderInfo.setTableId(String.valueOf(createOrderDTO.getTableId()));
|
||||
orderInfo.setSendType("table");
|
||||
orderInfo.setOrderType("cash");
|
||||
orderInfo.setShopId(createOrderDTO.getShopId().toString());
|
||||
orderInfo.setRefundAble(1);
|
||||
orderInfo.setTradeDay(day);
|
||||
orderInfo.setMasterId(createOrderDTO.getMasterId());
|
||||
orderInfo.setRemark(createOrderDTO.getNote());
|
||||
orderInfo.setUserId(createOrderDTO.getVipUserId() == null ? null : String.valueOf(createOrderDTO.getVipUserId()));
|
||||
orderInfo.setCreatedAt(DateUtil.current());
|
||||
orderInfo.setTableName(tbShopTable.getName());
|
||||
TbMerchantAccount merchantAccount = merchantAccountMapper.selectOne(new LambdaQueryWrapper<TbMerchantAccount>()
|
||||
.eq(TbMerchantAccount::getShopId, createOrderDTO.getShopId())
|
||||
.eq(TbMerchantAccount::getStatus, 1));
|
||||
if (merchantAccount == null) {
|
||||
throw new BadRequestException("商户信息不存在");
|
||||
orderInfo.setOrderAmount(totalAmount);
|
||||
orderInfo.setRemark(createOrderDTO.getNote());
|
||||
orderInfo.setFreightAmount(feeAmount);
|
||||
orderInfo.setProductAmount(saleAmount);
|
||||
orderInfo.setTradeDay(DateUtils.getDay());
|
||||
orderInfo.setUseType(createOrderDTO.isPostPay() ? "postPay" : "afterPay");
|
||||
orderInfo.setUserId(createOrderDTO.getVipUserId() == null ? null : String.valueOf(createOrderDTO.getVipUserId()));
|
||||
orderInfo.setCreatedAt(DateUtil.current());
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
} else {
|
||||
String orderNo = generateOrderNumber();
|
||||
orderInfo = new TbOrderInfo();
|
||||
orderInfo.setOrderNo(orderNo);
|
||||
orderInfo.setUseType(createOrderDTO.isPostPay() ? "postPay" : "afterPay");
|
||||
orderInfo.setAmount(totalAmount);
|
||||
orderInfo.setPayAmount(BigDecimal.ZERO);
|
||||
orderInfo.setPackFee(packAMount);
|
||||
orderInfo.setSettlementAmount(totalAmount);
|
||||
orderInfo.setOriginAmount(totalAmount);
|
||||
orderInfo.setProductAmount(saleAmount);
|
||||
orderInfo.setOrderAmount(totalAmount);
|
||||
orderInfo.setFreightAmount(feeAmount);
|
||||
orderInfo.setTableId(String.valueOf(createOrderDTO.getTableId()));
|
||||
orderInfo.setSendType("table");
|
||||
orderInfo.setOrderType("cash");
|
||||
orderInfo.setShopId(createOrderDTO.getShopId().toString());
|
||||
orderInfo.setRefundAble(1);
|
||||
orderInfo.setTradeDay(day);
|
||||
orderInfo.setMasterId(createOrderDTO.getMasterId());
|
||||
orderInfo.setOutNumber(createOrderDTO.getMasterId());
|
||||
orderInfo.setRemark(createOrderDTO.getNote());
|
||||
orderInfo.setUserId(createOrderDTO.getVipUserId() == null ? null : String.valueOf(createOrderDTO.getVipUserId()));
|
||||
orderInfo.setCreatedAt(DateUtil.current());
|
||||
orderInfo.setTableName(tbShopTable.getName());
|
||||
TbMerchantAccount merchantAccount = merchantAccountMapper.selectOne(new LambdaQueryWrapper<TbMerchantAccount>()
|
||||
.eq(TbMerchantAccount::getShopId, createOrderDTO.getShopId())
|
||||
.eq(TbMerchantAccount::getStatus, 1));
|
||||
if (merchantAccount == null) {
|
||||
throw new BadRequestException("商户信息不存在");
|
||||
}
|
||||
orderInfo.setMerchantId(merchantAccount.getId().toString());
|
||||
orderInfoMapper.insert(orderInfo);
|
||||
|
||||
redisTemplate.opsForValue().set(currentOrderKey, orderInfo.getId().toString());
|
||||
}
|
||||
orderInfo.setMerchantId(merchantAccount.getId().toString());
|
||||
orderInfoMapper.insert(orderInfo);
|
||||
}
|
||||
|
||||
|
||||
// 添加订单详细数据
|
||||
orderId = orderInfo.getId();
|
||||
for (TbOrderDetail orderDetail : orderDetails) {
|
||||
orderDetail.setOrderId(orderId);
|
||||
orderDetailMapper.insert(orderDetail);
|
||||
}
|
||||
// 添加订单详细数据
|
||||
orderId = orderInfo.getId();
|
||||
for (TbOrderDetail orderDetail : orderDetails) {
|
||||
orderDetail.setOrderId(orderId);
|
||||
orderDetailMapper.insert(orderDetail);
|
||||
}
|
||||
|
||||
// 更新购物车记录的orderId
|
||||
// 是否是第一次添加的商品
|
||||
boolean isFirst = true;
|
||||
for (TbCashierCart cashierCart : cashierCarts) {
|
||||
TbProduct product = productMapper.selectById(cashierCart.getProductId());
|
||||
TbProductSku productSku = productSkuRepository.findById(Integer.valueOf(cashierCart.getSkuId())).orElse(null);
|
||||
// 更新购物车记录的orderId
|
||||
// 是否是第一次添加的商品
|
||||
boolean isFirst = true;
|
||||
for (TbCashierCart cashierCart : cashierCarts) {
|
||||
TbProduct product = productMapper.selectById(cashierCart.getProductId());
|
||||
TbProductSku productSku = productSkuRepository.findById(Integer.valueOf(cashierCart.getSkuId())).orElse(null);
|
||||
|
||||
log.info("下单,开始校验库存预警,购物车id:{}", cashierCart.getId());
|
||||
CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(productSku, product, Integer.valueOf(cashierCart.getShopId()), cashierCart.getNumber()));
|
||||
log.info("下单,开始校验库存预警,购物车id:{}", cashierCart.getId());
|
||||
CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(productSku, product, Integer.valueOf(cashierCart.getShopId()), cashierCart.getNumber()));
|
||||
|
||||
// 已经添加的商品,修改数量
|
||||
isFirst = updateStock(cashierCart);
|
||||
cashierCart.setOrderId(orderId);
|
||||
cashierCart.setUpdatedAt(System.currentTimeMillis());
|
||||
cashierCart.setStatus("pending".equals(orderInfo.getStatus()) ? "refund" : cashierCart.getStatus());
|
||||
cashierCartMapper.updateById(cashierCart);
|
||||
}
|
||||
if (isFirst) {
|
||||
// 后付费,不增加当前台桌取餐号
|
||||
if (createOrderDTO.isPostPay()) {
|
||||
addGlobalCode(day, "pc", String.valueOf(createOrderDTO.getShopId()));
|
||||
// 已经添加的商品,修改数量
|
||||
isFirst = updateStock(cashierCart);
|
||||
cashierCart.setOrderId(orderId);
|
||||
cashierCart.setUpdatedAt(System.currentTimeMillis());
|
||||
cashierCart.setStatus("pending".equals(orderInfo.getStatus()) ? "refund" : cashierCart.getStatus());
|
||||
cashierCartMapper.updateById(cashierCart);
|
||||
}
|
||||
if (isFirst) {
|
||||
// 后付费,不增加当前台桌取餐号
|
||||
if (createOrderDTO.isPostPay()) {
|
||||
addGlobalCode(day, "pc", String.valueOf(createOrderDTO.getShopId()));
|
||||
// String key = "SHOP:CODE:USER:pc" + ":" + createOrderDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
|
||||
// redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
if (!createOrderDTO.isPostPay() || (addMaterId && "pending".equals(orderInfo.getStatus()))) {
|
||||
String key = "SHOP:CODE:USER:pc" + ":" + createOrderDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!createOrderDTO.isPostPay() || addMaterId){
|
||||
String key = "SHOP:CODE:USER:pc" + ":" + createOrderDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
|
||||
redisTemplate.delete(key);
|
||||
// 推送耗材信息
|
||||
pushConsMsg(orderInfo, cashierCarts);
|
||||
|
||||
|
||||
|
||||
if (createOrderDTO.isPostPay() && isPrint) {
|
||||
Long count = orderInfoMapper.selectCount(new LambdaQueryWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getStatus, "unpaid")
|
||||
.eq(TbOrderInfo::getId, orderId));
|
||||
if (count != 0) {
|
||||
rabbitMsgUtils.printTicket(String.valueOf(orderId));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getShopId, createOrderDTO.getShopId())
|
||||
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
|
||||
.set(TbShopTable::getStatus, TableStateEnum.USING.getState()));
|
||||
|
||||
// 推送耗材信息
|
||||
pushConsMsg(orderInfo, cashierCarts);
|
||||
String tableCartKey = RedisConstant.getTableCartKey(createOrderDTO.getTableId(), createOrderDTO.getShopId().toString());
|
||||
redisTemplate.delete(tableCartKey);
|
||||
return orderInfo;
|
||||
}, stringRedisTemplate, RedisConstant.getLockKey(RedisConstant.CREATE_ORDER,createOrderDTO.getShopId(),
|
||||
createOrderDTO.getTableId(), createOrderDTO.getMasterId(), createOrderDTO.isPostPay()));
|
||||
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getShopId, createOrderDTO.getShopId())
|
||||
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
|
||||
.set(TbShopTable::getStatus, TableStateEnum.USING.getState()));
|
||||
|
||||
if (createOrderDTO.isPostPay()) {
|
||||
rabbitMsgUtils.printTicket(String.valueOf(orderId));
|
||||
}
|
||||
|
||||
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -1007,7 +1149,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
createOrderDTO.setMasterId(pendingDTO.getMasterId());
|
||||
createOrderDTO.setVipUserId(pendingDTO.getVipUserId());
|
||||
createOrderDTO.setNote(pendingDTO.getNote());
|
||||
orderId = createOrder(createOrderDTO, true).getId();
|
||||
orderId = createOrder(createOrderDTO, true, false).getId();
|
||||
|
||||
}
|
||||
|
||||
@@ -1035,10 +1177,10 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, cashierCart.getTableId())
|
||||
.set(TbShopTable::getStatus, TableStateEnum.PENDING.getState()));
|
||||
|
||||
rabbitMsgUtils.printTicket(String.valueOf(orderId));
|
||||
}
|
||||
|
||||
redisTemplate.delete(RedisConstant.getCurrentOrderKey(pendingDTO.getTableId(), pendingDTO.getShopId().toString()));
|
||||
|
||||
return orderInfoMapper.selectById(orderId);
|
||||
}
|
||||
|
||||
@@ -1093,47 +1235,65 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
|
||||
@Override
|
||||
public Object pay(PayDTO payDTO) {
|
||||
return Utils.runFunAndCheckKey(() -> {
|
||||
TbOrderInfo orderInfo = null;
|
||||
switch (payDTO.getPayType()) {
|
||||
case "vipPay":
|
||||
orderInfo = tbPayServiceImpl.vipPay(payDTO.getShopId(), payDTO.getOrderId(), payDTO.getDiscount(), payDTO.getVipUserId());
|
||||
break;
|
||||
case "cash":
|
||||
orderInfo = tbPayServiceImpl.cashPay(payDTO);
|
||||
break;
|
||||
case "scanCode":
|
||||
orderInfo = tbPayServiceImpl.scanPay(payDTO);
|
||||
break;
|
||||
case "deposit":
|
||||
orderInfo = tbPayServiceImpl.memberAccountPay("", String.valueOf(payDTO.getShopId()), payDTO.getCode(), payDTO.getOrderId(), payDTO.getDiscount());
|
||||
break;
|
||||
default:
|
||||
throw new BadRequestException("未知支付方式");
|
||||
}
|
||||
|
||||
TbOrderInfo orderInfo = null;
|
||||
switch (payDTO.getPayType()) {
|
||||
case "vipPay":
|
||||
orderInfo = tbPayServiceImpl.vipPay(payDTO.getShopId(), payDTO.getOrderId(), payDTO.getDiscount(), payDTO.getVipUserId());
|
||||
break;
|
||||
case "cash":
|
||||
orderInfo = tbPayServiceImpl.cashPay(payDTO);
|
||||
break;
|
||||
default:
|
||||
throw new BadRequestException("未知支付方式");
|
||||
}
|
||||
log.info("更新购物车");
|
||||
|
||||
log.info("更新购物车");
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("token", null);
|
||||
jsonObject.put("type", "create");
|
||||
jsonObject.put("orderId", orderInfo.getId());
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("token", null);
|
||||
jsonObject.put("type", "create");
|
||||
jsonObject.put("orderId", orderInfo.getId());
|
||||
// 打印消息
|
||||
rabbitMsgUtils.sendOrderCollectMsg(jsonObject);
|
||||
rabbitMsgUtils.printTicket(String.valueOf(orderInfo.getId()));
|
||||
|
||||
// 打印消息
|
||||
rabbitMsgUtils.sendOrderCollectMsg(jsonObject);
|
||||
rabbitMsgUtils.printTicket(String.valueOf(orderInfo.getId()));
|
||||
// 发送库存记录mq消息
|
||||
JSONObject mqData = new JSONObject();
|
||||
mqData.put("orderId", payDTO.getOrderId());
|
||||
mqData.put("type", "pc");
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD_SALE, mqData.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
|
||||
|
||||
// 发送库存记录mq消息
|
||||
JSONObject mqData = new JSONObject();
|
||||
mqData.put("orderId", payDTO.getOrderId());
|
||||
mqData.put("type", "pc");
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD_SALE, mqData.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
|
||||
// 修改台桌状态
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
|
||||
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
|
||||
|
||||
if ("postPay".equals(orderInfo.getUseType())) {
|
||||
String day = DateUtils.getDay();
|
||||
String key = "SHOP:CODE:USER:pc" + ":" + payDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
|
||||
String currentOrderKey = RedisConstant.CURRENT_TABLE_ORDER + payDTO.getShopId() + ":" + orderInfo.getTableId();
|
||||
redisTemplate.delete(currentOrderKey);
|
||||
|
||||
// 小程序购物车缓存
|
||||
String tableCartKey = RedisConstant.getTableCartKey(orderInfo.getTableId(), orderInfo.getShopId());
|
||||
redisTemplate.delete(tableCartKey);
|
||||
|
||||
return null;
|
||||
}, stringRedisTemplate, RedisConstant.getLockKey("", payDTO.getShopId(), payDTO.getOrderId()));
|
||||
|
||||
// 修改台桌状态
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
|
||||
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
|
||||
|
||||
if ("postPay".equals(orderInfo.getUseType())) {
|
||||
String day = DateUtils.getDay();
|
||||
String key = "SHOP:CODE:USER:pc" + ":" + payDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,9 +32,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
@@ -252,7 +252,7 @@ public class TbShopUserServiceImpl implements TbShopUserService {
|
||||
flow.setShopUserId(tbShopUser.getId());
|
||||
flow.setAmount(amount);
|
||||
flow.setBalance(tbShopUser.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
flow.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ public interface TbShopTableService {
|
||||
|
||||
void pack(PackCartDTO packCartDTO);
|
||||
|
||||
Object createOrder(CreateOrderDTO createOrderDTO, boolean addMasterId);
|
||||
Object createOrder(CreateOrderDTO createOrderDTO, boolean addMasterId, boolean isPrint);
|
||||
|
||||
Object getMasterId(Integer shopId, Long tableId, Integer vipUserId);
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ package cn.ysk.cashier.thirdpay.service;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
|
||||
import cn.ysk.cashier.mybatis.vo.pay.MainScanReq;
|
||||
import cn.ysk.cashier.mybatis.vo.pay.MainScanResp;
|
||||
import cn.ysk.cashier.thirdpay.constants.SignTypeEnum;
|
||||
import cn.ysk.cashier.thirdpay.req.OrderRefundReq;
|
||||
import cn.ysk.cashier.thirdpay.req.OrderReturnQueryReq;
|
||||
@@ -11,6 +13,7 @@ import cn.ysk.cashier.thirdpay.resp.OrderReturnResp;
|
||||
import cn.ysk.cashier.thirdpay.resp.OrderStatusQueryResp;
|
||||
import cn.ysk.cashier.thirdpay.resp.PublicResp;
|
||||
import cn.ysk.cashier.utils.JSONUtil;
|
||||
import cn.ysk.cashier.utils.MD5Util;
|
||||
import cn.ysk.cashier.utils.MD5Utils;
|
||||
import com.dianguang.cloud.ossservice.model.DateUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -25,6 +28,13 @@ import java.util.LinkedHashMap;
|
||||
@Slf4j
|
||||
public class ThirdPayService {
|
||||
|
||||
private static String micropay="/api/open/payment/micropay";
|
||||
|
||||
private static String ltpay="/api/open/payment/ltpay";
|
||||
|
||||
|
||||
private static String refund="/api/open/order/refund";
|
||||
|
||||
|
||||
private static String trade="/api/open/query/trade";
|
||||
|
||||
@@ -197,6 +207,45 @@ public class ThirdPayService {
|
||||
return map;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PublicParam param = new PublicParam(appId, "", SignTypeEnum.MD5.getValue(), null, cn.ysk.cashier.utils.DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
|
||||
try {
|
||||
String str = JSONUtil.toJSONString(sortFields(mainScanReq));
|
||||
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(micropay)).body(reqbody).execute().body();
|
||||
log.info("返回结果:{}", response);
|
||||
PublicResp<MainScanResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
||||
|
||||
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),MainScanResp.class));
|
||||
return resp;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
360
eladmin-system/src/main/java/cn/ysk/cashier/utils/DateUtils.java
Normal file
360
eladmin-system/src/main/java/cn/ysk/cashier/utils/DateUtils.java
Normal file
@@ -0,0 +1,360 @@
|
||||
package cn.ysk.cashier.utils;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by SEELE on 2018/4/19.
|
||||
*/
|
||||
public class DateUtils {
|
||||
|
||||
private final static SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
|
||||
private final static SimpleDateFormat sdfDay = new SimpleDateFormat("yyyy-MM-dd");
|
||||
private final static SimpleDateFormat sdfDays = new SimpleDateFormat("yyyyMMdd");
|
||||
private final static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private final static SimpleDateFormat sdfTimeSS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
private final static SimpleDateFormat sdfTimes = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
|
||||
|
||||
private final static SimpleDateFormat sdfTimesSs = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
||||
|
||||
|
||||
|
||||
private final static SimpleDateFormat sdfday = new SimpleDateFormat("MM-dd HH:mm");
|
||||
|
||||
|
||||
public static Date getNewDate(Date date, Integer type, Integer interval) throws ParseException {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(date);
|
||||
switch (type) {
|
||||
case 1:
|
||||
c.set(Calendar.YEAR, (c.get(Calendar.YEAR) + interval));
|
||||
break;
|
||||
case 2:
|
||||
c.set(Calendar.MONTH, (c.get(Calendar.MONTH) + interval));
|
||||
break;
|
||||
case 3:
|
||||
c.set(Calendar.DATE, (c.get(Calendar.DATE) + interval));
|
||||
break;
|
||||
case 4:
|
||||
c.set(Calendar.HOUR, (c.get(Calendar.HOUR) + interval));
|
||||
break;
|
||||
case 5:
|
||||
c.set(Calendar.MINUTE, (c.get(Calendar.MINUTE) + interval));
|
||||
break;
|
||||
default:
|
||||
c.set(Calendar.SECOND, (c.get(Calendar.SECOND) + interval));
|
||||
break;
|
||||
}
|
||||
Date newDate = c.getTime();
|
||||
return sdfTime.parse(sdfTime.format(newDate));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取YYYY格式
|
||||
* @return
|
||||
*/
|
||||
public static String getSdfTimes() {
|
||||
return sdfTimes.format(new Date());
|
||||
}
|
||||
|
||||
|
||||
public static String getSsdfTimes() {
|
||||
return sdfTimesSs.format(new Date());
|
||||
}
|
||||
|
||||
public static String getNextSdfTimes(Date date){
|
||||
return sdfTimes.format(date);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String getTimes(Date date){
|
||||
return sdfday.format(date);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取YYYY格式
|
||||
* @return
|
||||
*/
|
||||
public static String getYear() {
|
||||
return sdfYear.format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取YYYY-MM-DD格式
|
||||
* @return
|
||||
*/
|
||||
public static String getDay() {
|
||||
return sdfDay.format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取YYYYMMDD格式
|
||||
* @return
|
||||
*/
|
||||
public static String getDays(){
|
||||
return sdfDays.format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取YYYY-MM-DD HH:mm:ss格式
|
||||
* @return
|
||||
*/
|
||||
public static String getTime(Date date) {
|
||||
return sdfTime.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Title: compareDate
|
||||
* @Description: TODO(日期比较,如果s>=e 返回true 否则返回false)
|
||||
* @param s
|
||||
* @param e
|
||||
* @return boolean
|
||||
* @throws
|
||||
* @author fh
|
||||
*/
|
||||
public static boolean compareDate(String s, String e) {
|
||||
if(fomatDate(s)==null||fomatDate(e)==null){
|
||||
return false;
|
||||
}
|
||||
return fomatDate(s).getTime() >=fomatDate(e).getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化日期
|
||||
* @return
|
||||
*/
|
||||
public static Date fomatDate(String date) {
|
||||
DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
return fmt.parse(date);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验日期是否合法
|
||||
* @return
|
||||
*/
|
||||
public static boolean isValidDate(String s) {
|
||||
DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
fmt.parse(s);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
// 如果throw java.text.ParseException或者NullPointerException,就说明格式不对
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
public static int getDiffYear(String startTime,String endTime) {
|
||||
DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
//long aa=0;
|
||||
int years=(int) (((fmt.parse(endTime).getTime()-fmt.parse(startTime).getTime())/ (1000 * 60 * 60 * 24))/365);
|
||||
return years;
|
||||
} catch (Exception e) {
|
||||
// 如果throw java.text.ParseException或者NullPointerException,就说明格式不对
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <li>功能描述:时间相减得到天数
|
||||
* @param beginDateStr
|
||||
* @param endDateStr
|
||||
* @return
|
||||
* long
|
||||
* @author Administrator
|
||||
*/
|
||||
public static long getDaySub(String beginDateStr,String endDateStr){
|
||||
long day=0;
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date beginDate = null;
|
||||
Date endDate = null;
|
||||
|
||||
try {
|
||||
beginDate = format.parse(beginDateStr);
|
||||
endDate= format.parse(endDateStr);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
day=(endDate.getTime()-beginDate.getTime())/(24*60*60*1000);
|
||||
//System.out.println("相隔的天数="+day);
|
||||
|
||||
return day;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到n天之后的日期
|
||||
* @param days
|
||||
* @return
|
||||
*/
|
||||
public static String getAfterDayDate(String days) {
|
||||
int daysInt = Integer.parseInt(days);
|
||||
|
||||
Calendar canlendar = Calendar.getInstance(); // java.util包
|
||||
canlendar.add(Calendar.DATE, daysInt); // 日期减 如果不够减会将月变动
|
||||
Date date = canlendar.getTime();
|
||||
|
||||
SimpleDateFormat sdfd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateStr = sdfd.format(date);
|
||||
|
||||
return dateStr;
|
||||
}
|
||||
/**
|
||||
* 得到n天之后的日期
|
||||
* @param days
|
||||
* @return
|
||||
*/
|
||||
public static String getAfterDate(Date openDate,String days) {
|
||||
int daysInt = Integer.parseInt(days);
|
||||
|
||||
Calendar canlendar = Calendar.getInstance(); // java.util包
|
||||
canlendar.setTime(openDate);
|
||||
canlendar.add(Calendar.DATE, daysInt); // 日期减 如果不够减会将月变动
|
||||
Date date = canlendar.getTime();
|
||||
SimpleDateFormat sdfd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateStr = sdfd.format(date);
|
||||
return dateStr;
|
||||
}
|
||||
public static String getAfterDate1(Date openDate,String year) {
|
||||
int daysInt = Integer.parseInt(year);
|
||||
|
||||
Calendar canlendar = Calendar.getInstance(); // java.util包
|
||||
canlendar.setTime(openDate);
|
||||
canlendar.add(Calendar.YEAR, daysInt); // 日期减 如果不够减会将月变动
|
||||
Date date = canlendar.getTime();
|
||||
SimpleDateFormat sdfd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateStr = sdfd.format(date);
|
||||
return dateStr;
|
||||
}
|
||||
public static Date getAfterDateStr(Date openDate,String days) {
|
||||
int daysInt = Integer.parseInt(days);
|
||||
|
||||
Calendar canlendar = Calendar.getInstance(); // java.util包
|
||||
canlendar.setTime(openDate);
|
||||
canlendar.add(Calendar.DATE, daysInt); // 日期减 如果不够减会将月变动
|
||||
Date date = canlendar.getTime();
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到n天之后是周几
|
||||
* @param days
|
||||
* @return
|
||||
*/
|
||||
public static String getAfterDayWeek(String days) {
|
||||
int daysInt = Integer.parseInt(days);
|
||||
Calendar canlendar = Calendar.getInstance(); // java.util包
|
||||
canlendar.add(Calendar.DATE, daysInt); // 日期减 如果不够减会将月变动
|
||||
Date date = canlendar.getTime();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("E");
|
||||
String dateStr = sdf.format(date);
|
||||
return dateStr;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(getTimes(new Date()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化日期为时分秒
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static Date fomatDateTime(String date) {
|
||||
DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
try {
|
||||
return fmt.parse(date);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Date fomatDateTime1(String date) {
|
||||
DateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
try {
|
||||
return fmt.parse(date);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Date parse(String dateString, String dateFormat) {
|
||||
if ("".equals(dateString.trim()) || dateString == null) {
|
||||
return null;
|
||||
}
|
||||
DateFormat sdf = new SimpleDateFormat(dateFormat);
|
||||
Date date = null;
|
||||
try {
|
||||
date = sdf.parse(dateString);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
private final static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
public static Date convertDate(String date) {
|
||||
try {
|
||||
return sdf.parse(date);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private final static SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
public static Date convertDateByString(String str){
|
||||
StringBuilder sb=new StringBuilder();
|
||||
sb.append(str.substring(0,4));
|
||||
sb.append("-");
|
||||
sb.append(str.substring(4,6));
|
||||
sb.append("-");
|
||||
sb.append(str.substring(6,8));
|
||||
sb.append(" ");
|
||||
sb.append(str.substring(8,10));
|
||||
sb.append(":");
|
||||
sb.append(str.substring(10,12));
|
||||
sb.append(":");
|
||||
sb.append(str.substring(12,14));
|
||||
|
||||
return convertDate1(sb.toString());
|
||||
}
|
||||
|
||||
public static Date convertDate1(String date) {
|
||||
try {
|
||||
return sdf1.parse(date);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String formatDateToStr(Date date) {
|
||||
return sdfTime.format(date);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,19 @@
|
||||
package cn.ysk.cashier.utils;
|
||||
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class Utils {
|
||||
public static int retryCount = 5;
|
||||
private static final Logger log = LoggerFactory.getLogger(Utils.class);
|
||||
|
||||
public static <T> void catchErrNoReturn(Supplier<T> supplier) {
|
||||
@@ -15,4 +23,72 @@ public class Utils {
|
||||
log.error("执行方法出现异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T, R> void runFunAndRetryNoReturn(
|
||||
Supplier<R> function,
|
||||
Function<R, Boolean> check, Consumer<R> errFun) {
|
||||
log.info("工具类开始执行函数");
|
||||
R result = function.get();
|
||||
boolean flag = check.apply(result);
|
||||
|
||||
log.info("执行结果: {}", result);
|
||||
|
||||
while (flag && retryCount-- > 0) {
|
||||
log.info("执行函数失败, 剩余尝试次数{}", retryCount);
|
||||
result = function.get();
|
||||
log.info("执行结果: {}", result);
|
||||
flag = check.apply(result);
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
errFun.accept(result);
|
||||
}
|
||||
}
|
||||
|
||||
public static<T> T runFunAndCheckKey(Supplier<T> supplier, StringRedisTemplate redisTemplate, String lockKey) {
|
||||
try{
|
||||
// 创建线程id, 用作判断
|
||||
String clientId = UUID.randomUUID().toString();
|
||||
// 设置分布式锁
|
||||
boolean lock = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(lockKey, clientId, 30, TimeUnit.MILLISECONDS));
|
||||
int count = 0;
|
||||
while (!lock) {
|
||||
if (count++ > 100) {
|
||||
throw new BadRequestException("系统繁忙, 稍后再试");
|
||||
}
|
||||
Thread.sleep(20);
|
||||
lock = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(lockKey, clientId, 30, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
return supplier.get();
|
||||
} catch (RuntimeException e){
|
||||
log.info("执行出错:{}", e.getMessage());
|
||||
throw e;
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally{
|
||||
redisTemplate.delete(lockKey);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T, R> R runFunAndRetry(
|
||||
Supplier<R> function,
|
||||
Function<R, Boolean> check, Consumer<R> errFun) {
|
||||
log.info("工具类开始执行函数");
|
||||
R result = function.get();
|
||||
boolean flag = check.apply(result);
|
||||
|
||||
log.info("执行结果: {}", result);
|
||||
|
||||
while (flag && retryCount-- > 0) {
|
||||
log.info("执行函数失败, 剩余尝试次数{}", retryCount);
|
||||
result = function.get();
|
||||
log.info("执行结果: {}", result);
|
||||
flag = check.apply(result);
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
errFun.accept(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,6 +219,8 @@ public class TbProductVo {
|
||||
|
||||
private String skuSnap;
|
||||
|
||||
private BigDecimal maxPrice;
|
||||
|
||||
private TbPurchaseNotice notices=new TbPurchaseNotice();
|
||||
private List<TbCouponCategoryDto> groupCategoryId = new ArrayList<>();
|
||||
private List<TbPlatformDictDto> tags = new ArrayList<>();
|
||||
|
||||
@@ -4,6 +4,7 @@ spring:
|
||||
druid:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
# driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
#内网地址
|
||||
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
|
||||
# url: jdbc:mysql://127.0.0.1:3306/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
|
||||
username: cashier
|
||||
|
||||
@@ -60,6 +60,8 @@ qrcode: https://kysh.sxczgkj.cn/codeplate?code=
|
||||
|
||||
thirdPay:
|
||||
groupCallBack: https://wxcashiertest.sxczgkj.cn/cashierService/notify/notifyCallBackGroup
|
||||
payType: fushangtong
|
||||
callBack: https://cashierclient.sxczgkj.cn/cashier-client/notify/notifyPay
|
||||
url: https://paymentapi.sxczgkj.cn
|
||||
|
||||
mybatis-plus:
|
||||
@@ -85,3 +87,9 @@ wx:
|
||||
secrete: 8492a7e8d55bbb1b57f5c8276ea1add0
|
||||
operationMsgTmpId: wFdoUG-dUT7bDRHq8bMJD9CF5TjyH9x_uJQgQByZqHg
|
||||
warnMsgTmpId: C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0
|
||||
|
||||
|
||||
gateway:
|
||||
url: https://gateway.api.sxczgkj.cn/gate-service/
|
||||
client:
|
||||
backUrl: https://cashierclient.sxczgkj.cn/cashier-client/notify/notifyPay
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.ysk.cashier.mybatis.mapper.TbActivateMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.ysk.cashier.mybatis.pojo.TbActivatetb">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="shop_id" column="shop_id" jdbcType="INTEGER"/>
|
||||
<result property="min_num" column="min_num" jdbcType="INTEGER"/>
|
||||
<result property="max_num" column="max_num" jdbcType="INTEGER"/>
|
||||
<result property="handsel_num" column="handsel_num" jdbcType="DECIMAL"/>
|
||||
<result property="handsel_type" column="handsel_type" jdbcType="VARCHAR"/>
|
||||
<result property="is_del" column="is_del" jdbcType="VARCHAR"/>
|
||||
<result property="is_user" column="is_user" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,shop_id,min_num,
|
||||
max_num,handsel_num,handsel_type,
|
||||
is_del,is_user
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -39,6 +39,11 @@
|
||||
<version>2.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>sts20150401</artifactId>
|
||||
<version>1.1.4</version>
|
||||
</dependency>
|
||||
<!--支付宝依赖-->
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
|
||||
@@ -1,27 +1,14 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.rest;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
|
||||
import cn.ysk.cashier.domain.QiniuConfig;
|
||||
import cn.ysk.cashier.domain.QiniuContent;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.service.QiNiuService;
|
||||
import cn.ysk.cashier.service.dto.QiniuQueryCriteria;
|
||||
import com.aliyun.sts20150401.models.AssumeRoleResponse;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -77,7 +64,7 @@ public class QiniuController {
|
||||
return new ResponseEntity<>(qiNiuService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("上传版本文件")
|
||||
@Log("上传文件")
|
||||
@ApiOperation("上传文件")
|
||||
@AnonymousPostMapping
|
||||
public ResponseEntity<Object> uploadQiNiu(@RequestParam MultipartFile file){
|
||||
@@ -89,13 +76,34 @@ public class QiniuController {
|
||||
return new ResponseEntity<>(map,HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("上传PC版本文件")
|
||||
@AnonymousPostMapping("uploadVersionFile")
|
||||
public ResponseEntity<Object> uploadVersionFile(@RequestParam MultipartFile file,@RequestParam String name){
|
||||
String url = qiNiuService.uploadVersionFile(file,qiNiuService.findCloud(),name);
|
||||
Map<String,Object> map = new HashMap<>(1);
|
||||
map.put("data",url);
|
||||
return new ResponseEntity<>(map,HttpStatus.OK);
|
||||
@GetMapping(value = "/getCredentials")
|
||||
@ApiOperation("获取上传临时凭证")
|
||||
public ResponseEntity<Object> getCredentials() {
|
||||
try {
|
||||
com.aliyun.sts20150401.Client client = new com.aliyun.sts20150401.Client(qiNiuService.findTempCloud());
|
||||
com.aliyun.sts20150401.models.AssumeRoleRequest assumeRoleRequest = new com.aliyun.sts20150401.models.AssumeRoleRequest();
|
||||
assumeRoleRequest.setRoleArn("acs:ram::1413456038175003:role/oss");
|
||||
assumeRoleRequest.setRoleSessionName("test");
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
AssumeRoleResponse response = client.assumeRoleWithOptions(assumeRoleRequest, runtime);
|
||||
return new ResponseEntity<>(response.getBody().getCredentials(),HttpStatus.OK);
|
||||
} catch (TeaException error) {
|
||||
throw new BadRequestException("获取失败,请联系管理员。"+error.getMessage());
|
||||
// System.out.println(error.getMessage());
|
||||
// 诊断地址
|
||||
// System.out.println(error.getData().get("Recommend"));
|
||||
// com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
} catch (Exception _error) {
|
||||
throw new BadRequestException("获取失败,请联系管理员。"+ _error.getMessage());
|
||||
// TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// // 错误 message
|
||||
// System.out.println(error.getMessage());
|
||||
// // 诊断地址
|
||||
// System.out.println(error.getData().get("Recommend"));
|
||||
// com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import cn.ysk.cashier.service.dto.QiniuQueryCriteria;
|
||||
import com.dianguang.cloud.ossservice.config.CloudStorageConfig;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
@@ -41,6 +42,8 @@ public interface QiNiuService {
|
||||
|
||||
CloudStorageConfig findCloud();
|
||||
|
||||
Config findTempCloud();
|
||||
|
||||
/**
|
||||
* 修改配置
|
||||
* @param qiniuConfig 配置
|
||||
|
||||
@@ -1,23 +1,9 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.ysk.cashier.domain.QiniuConfig;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
import com.dianguang.cloud.ossservice.config.CloudStorageConfig;
|
||||
import com.dianguang.cloud.ossservice.service.OSSFactory;
|
||||
import com.qiniu.common.QiniuException;
|
||||
@@ -93,6 +79,25 @@ public class QiNiuServiceImpl implements QiNiuService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Config findTempCloud() {
|
||||
Optional<QiniuConfig> qiniuConfig = qiNiuConfigRepository.findById(1L);
|
||||
QiniuConfig config= qiniuConfig.orElseGet(QiniuConfig::new);
|
||||
if(ObjectUtil.isNotEmpty(config)){
|
||||
com.aliyun.teaopenapi.models.Config config1 = new com.aliyun.teaopenapi.models.Config()
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||
// .setAccessKeyId(System.getenv("LTAI5tPdEfYSZcqHbjCrtPRD"))
|
||||
.setAccessKeyId(qiniuConfig.get().getAccessKey())
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||
.setAccessKeySecret(qiniuConfig.get().getSecretKey());
|
||||
// Endpoint 请参考 https://api.aliyun.com/product/Sts
|
||||
config1.endpoint = "sts.cn-hangzhou.aliyuncs.com";
|
||||
return config1;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@CachePut(key = "'config'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
Reference in New Issue
Block a user