Merge remote-tracking branch 'origin/test' into dev
This commit is contained in:
commit
1c5fb88b38
|
|
@ -28,18 +28,29 @@ public class TbVersionController {
|
|||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("版本管理 新增")
|
||||
@ApiOperation("新增版本")
|
||||
public ResponseEntity<Object> createTbVersion(@Validated @RequestBody TbVersion resources){
|
||||
return new ResponseEntity<>(tbVersionService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("版本管理 修改")
|
||||
@ApiOperation("修改版本")
|
||||
public ResponseEntity<Object> updateTbVersion(@Validated @RequestBody TbVersion resources){
|
||||
tbVersionService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PutMapping("upSel")
|
||||
@Log("版本管理 修改选中")
|
||||
@ApiOperation("修改当前选中")
|
||||
public ResponseEntity<Object> updateSel(@Validated @RequestBody TbVersion resources){
|
||||
tbVersionService.updateSel(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation("删除版本")
|
||||
public ResponseEntity<Object> deleteTbVersion(@RequestBody Integer[] ids) {
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ public class TbPlaceController {
|
|||
public ResponseEntity<Object> createOrder(
|
||||
@RequestBody CreateOrderDTO createOrderDTO
|
||||
) {
|
||||
return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO, true));
|
||||
return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO, !createOrderDTO.isPostPay()));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopExtend;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopExtendService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
|
@ -51,8 +53,11 @@ public class TbShopExtendController {
|
|||
@PutMapping
|
||||
@ApiOperation("通过id修改")
|
||||
public ResponseEntity<Object> update(@RequestBody TbShopExtend tbShopExtend) {
|
||||
tbShopExtend.setUpdateTime(new Date());
|
||||
tbShopExtendService.updateById(tbShopExtend);
|
||||
if (tbShopExtend.getId() != null) {
|
||||
tbShopExtendService.updateById(tbShopExtend);
|
||||
} else {
|
||||
tbShopExtendService.saveInfo(tbShopExtend);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class TbVersionDto implements Serializable {
|
|||
|
||||
private Integer id;
|
||||
|
||||
/** LDBL_APP;WX; */
|
||||
/** PC;APP; */
|
||||
private String source;
|
||||
|
||||
/** ios;android; */
|
||||
|
|
@ -22,9 +22,12 @@ public class TbVersionDto implements Serializable {
|
|||
|
||||
/** 版本号 */
|
||||
private String version;
|
||||
/** 下载地址 */
|
||||
private String url;
|
||||
|
||||
/** 0:不更新;1:更新 */
|
||||
/** 是否强制更新 0:否 1:是 */
|
||||
private Integer isUp;
|
||||
private Integer sel;
|
||||
|
||||
/** 更新提示内容 */
|
||||
private String message;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import lombok.Data;
|
|||
public class TbVersionQueryCriteria{
|
||||
|
||||
@Query
|
||||
/** LDBL-APP;WX; */
|
||||
/** PC;APP; */
|
||||
private String source;
|
||||
@Query
|
||||
/** ios;android; */
|
||||
|
|
@ -21,7 +21,7 @@ public class TbVersionQueryCriteria{
|
|||
/** 版本号 */
|
||||
private String version;
|
||||
@Query
|
||||
/** 0:不更新;1:更新 */
|
||||
/** 是否强制更新 0:否 1:是*/
|
||||
private Integer isUp;
|
||||
|
||||
private Integer pageSize;
|
||||
|
|
|
|||
|
|
@ -9,12 +9,15 @@ import javax.persistence.Id;
|
|||
public class StockCountDTO {
|
||||
private String shopId;
|
||||
@Id
|
||||
private Long skuId;
|
||||
private Long proId;
|
||||
private String proName;
|
||||
private Integer isStock;
|
||||
private String skuName;
|
||||
private String unitName;
|
||||
// 消耗数
|
||||
private Integer stockCount;
|
||||
// 当前库存
|
||||
private Integer stockNumber;
|
||||
private String specSnap;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,4 +24,5 @@ public class AddCartDTO {
|
|||
private Integer num;
|
||||
private boolean isPack;
|
||||
private boolean isGift;
|
||||
private Integer cartId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class CreateOrderDTO {
|
|||
@NotNull
|
||||
private Integer shopId;
|
||||
@NotEmpty
|
||||
private Long tableId;
|
||||
private String tableId;
|
||||
private String note;
|
||||
private boolean postPay;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package cn.ysk.cashier.dto.shoptable;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
|
@ -13,4 +15,8 @@ public class PayDTO {
|
|||
private Integer orderId;
|
||||
@NotEmpty
|
||||
private String payType;
|
||||
@Min(0)
|
||||
@Max(1)
|
||||
private Double discount;
|
||||
private Integer vipUserId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public class PendingDTO {
|
|||
private String masterId;
|
||||
@NotNull
|
||||
private Integer shopId;
|
||||
private Long tableId;
|
||||
private String tableId;
|
||||
private Integer vipUserId;
|
||||
@NotNull
|
||||
private Boolean isPending;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package cn.ysk.cashier.mybatis.entity;
|
|||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -24,6 +25,7 @@ public class TbShopExtend extends Model<TbShopExtend> {
|
|||
private String autokey;
|
||||
//值
|
||||
private String value;
|
||||
private String detail;
|
||||
//更新时间
|
||||
private Date updateTime;
|
||||
//创建时间
|
||||
|
|
@ -93,5 +95,47 @@ public class TbShopExtend extends Model<TbShopExtend> {
|
|||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
|
||||
public String getDetail() {
|
||||
return detail;
|
||||
}
|
||||
|
||||
public void setDetail(String detail) {
|
||||
this.detail = detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* index_bg:店铺首页背景图
|
||||
* my_bg: 我的页面背景图
|
||||
* member_bg:会员卡页面背景图
|
||||
* shopinfo_bg:商品列表顶部背景图
|
||||
* @param autokey
|
||||
*/
|
||||
public void initAutoKey(String autokey,Integer shopId) {
|
||||
if (StringUtils.isBlank(name)) {
|
||||
switch (autokey) {
|
||||
case "index_bg":
|
||||
this.name = "店铺首页背景图";
|
||||
this.detail="建议尺寸: 375*600 ";
|
||||
break;
|
||||
case "my_bg":
|
||||
this.name = "我的页面背景图";
|
||||
this.detail="建议尺寸: 375*200";
|
||||
break;
|
||||
case "member_bg":
|
||||
this.name = "会员卡页面背景图";
|
||||
this.detail="建议尺寸: 315*152";
|
||||
break;
|
||||
case "shopinfo_bg":
|
||||
this.name = "商品列表顶部背景图";
|
||||
this.detail="建议尺寸: 375*120";
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.type="img";
|
||||
this.shopId=shopId;
|
||||
this.autokey = autokey;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import org.apache.ibatis.annotations.Select;
|
|||
public interface ShopUserMapper extends BaseMapper<TbShopUser> {
|
||||
|
||||
@Select("<script>" +
|
||||
"SELECT su.id as id, su.head_img as headImg, su.name as nickName, su.sex as sex, " +
|
||||
"SELECT su.id as id, su.user_id as user_id, su.head_img as headImg, su.name as nickName, su.sex as sex, " +
|
||||
"su.amount as amount, 0 as totalScore, su.telephone as telephone, u.last_log_in_at as lastLoginAt, " +
|
||||
"su.birth_day as birthDay, su.is_vip as isVip, su.created_at as createAt " +
|
||||
"FROM tb_shop_user su " +
|
||||
|
|
|
|||
|
|
@ -2,13 +2,10 @@ package cn.ysk.cashier.mybatis.mapper;
|
|||
|
||||
import cn.ysk.cashier.pojo.product.TbProductSku;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TbProducSkutMapper extends BaseMapper<TbProductSku> {
|
||||
|
||||
|
|
@ -22,6 +19,9 @@ public interface TbProducSkutMapper extends BaseMapper<TbProductSku> {
|
|||
@Update("update tb_product_sku set stock_number=stock_number+#{addNum} WHERE id=#{skuId}")
|
||||
int incrStock(@Param("skuId") Integer skuId, @Param("addNum") Integer addNum);
|
||||
|
||||
@Update("update tb_product_sku set real_sales_number=real_sales_number+#{num} WHERE id=#{skuId}")
|
||||
int incrRealSalesNumber(@Param("skuId") Integer skuId, @Param("num") Integer num);
|
||||
|
||||
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id} and stock_number-#{num} >= 0")
|
||||
int decrStock(String id, int num);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import cn.ysk.cashier.utils.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 店铺扩展信息(TbShopExtend)表服务实现类
|
||||
|
|
@ -40,6 +41,7 @@ public class TbShopExtendServiceImpl extends ServiceImpl<TbShopExtendMapper, TbS
|
|||
}
|
||||
wrapper.orderByDesc("create_time");
|
||||
Page<TbShopExtend> ipage = tbShopExtendmapper.selectPage(page, wrapper);
|
||||
checkAndInitialize(ipage,criteria.getShopId());
|
||||
return PageUtil.toPage(ipage.getRecords(), ipage.getTotal());
|
||||
}
|
||||
|
||||
|
|
@ -53,5 +55,43 @@ public class TbShopExtendServiceImpl extends ServiceImpl<TbShopExtendMapper, TbS
|
|||
}
|
||||
tbShopExtendmapper.insert(tbShopExtend);
|
||||
}
|
||||
|
||||
public Page<TbShopExtend> checkAndInitialize(Page<TbShopExtend> ipage, Integer shopId) {
|
||||
List<TbShopExtend> newRecords = new ArrayList<>();
|
||||
List<String> requiredAutokeys = Arrays.asList("index_bg", "my_bg", "member_bg", "shopinfo_bg");
|
||||
|
||||
if (ipage == null || ipage.getRecords() == null || ipage.getRecords().isEmpty()) {
|
||||
// ipage 为空,直接创建包含四种类型数据的新 Page 对象
|
||||
for (String key : requiredAutokeys) {
|
||||
TbShopExtend newRecord = new TbShopExtend();
|
||||
newRecord.initAutoKey(key, shopId);
|
||||
newRecords.add(newRecord);
|
||||
}
|
||||
return new Page<TbShopExtend>(1, newRecords.size(), newRecords.size()) // pageNum, pageSize, total
|
||||
.setRecords(newRecords);
|
||||
} else {
|
||||
// ipage 不为空,补充缺失的数据
|
||||
List<TbShopExtend> shopExtends = ipage.getRecords();
|
||||
Set<String> existingAutokeys = shopExtends.stream()
|
||||
.map(TbShopExtend::getAutokey)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
List<String> missingAutokeys = requiredAutokeys.stream()
|
||||
.filter(key -> !existingAutokeys.contains(key))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (String key : missingAutokeys) {
|
||||
TbShopExtend newRecord = new TbShopExtend();
|
||||
newRecord.initAutoKey(key, shopId);
|
||||
newRecords.add(newRecord);
|
||||
}
|
||||
|
||||
// 更新现有记录并将新记录添加到原来的列表中
|
||||
shopExtends.addAll(newRecords);
|
||||
|
||||
return new Page<TbShopExtend>(ipage.getCurrent(), ipage.getSize(), ipage.getTotal() + newRecords.size())
|
||||
.setRecords(shopExtends);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class TbVersion implements Serializable {
|
|||
private Integer id;
|
||||
|
||||
@Column(name = "`source`")
|
||||
@ApiModelProperty(value = "LDBL-APP;WX;")
|
||||
@ApiModelProperty(value = "PC;APP;")
|
||||
private String source;
|
||||
|
||||
@Column(name = "`type`")
|
||||
|
|
@ -30,10 +30,17 @@ public class TbVersion implements Serializable {
|
|||
@ApiModelProperty(value = "版本号")
|
||||
private String version;
|
||||
|
||||
@Column(name = "`url`")
|
||||
@ApiModelProperty(value = "下载地址")
|
||||
private String url;
|
||||
|
||||
@Column(name = "`is_up`")
|
||||
@ApiModelProperty(value = "0:不更新;1:更新")
|
||||
@ApiModelProperty(value = "是否强制更新 0:否 1:是")
|
||||
private Integer isUp;
|
||||
|
||||
@ApiModelProperty(value = "选中 0:否 1:是")
|
||||
private Integer sel;
|
||||
|
||||
@Column(name = "`message`")
|
||||
@ApiModelProperty(value = "更新提示内容")
|
||||
private String message;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import cn.ysk.cashier.pojo.TbVersion;
|
|||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
/**
|
||||
|
|
@ -15,4 +16,15 @@ public interface TbVersionRepository extends JpaRepository<TbVersion, Integer>,
|
|||
|
||||
@Query("SELECT count(1) FROM TbVersion WHERE source = :source AND type =:type AND version =:version")
|
||||
int isExist(@Param("source") String source, @Param("type") String type, @Param("version") String version);
|
||||
|
||||
@Query("SELECT count(1) FROM TbVersion WHERE source = :source AND version =:version")
|
||||
int isExist(@Param("source") String source, @Param("version") String version);
|
||||
|
||||
@Modifying
|
||||
@Query("update TbVersion version set version.sel=CASE" +
|
||||
" WHEN version.source=:source AND version.id=:id THEN 1 " +
|
||||
" WHEN version.source=:source AND version.id!=:id THEN 0 " +
|
||||
" ELSE version.sel END " +
|
||||
" WHERE version.source = :source")
|
||||
int updateSelBySource(@Param("source") String source, @Param("id") Integer id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,10 @@ public interface StockCountRepository extends JpaRepository<StockCountDTO, Integ
|
|||
List<StockCountDTO> countStock( @Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
|
||||
@Query(value = "SELECT\n" +
|
||||
"pro.shop_id AS shop_id,\n" +
|
||||
"pro.id AS pro_id,\n" +
|
||||
"info.shop_id AS shop_id,\n" +
|
||||
"info.product_id AS pro_id,\n" +
|
||||
"info.product_name AS pro_name,\n" +
|
||||
"info.product_sku_id AS sku_id,\n" +
|
||||
"pro.is_stock,\n" +
|
||||
"info.product_sku_name AS sku_name,\n" +
|
||||
"unit.NAME AS unit_name,\n" +
|
||||
|
|
@ -57,11 +58,6 @@ public interface StockCountRepository extends JpaRepository<StockCountDTO, Integ
|
|||
"AND ( info.STATUS = 'closed' OR info.STATUS = 'refund' ) \n" +
|
||||
"GROUP BY\n" +
|
||||
"info.product_id,\n" +
|
||||
"pro.shop_id,\n" +
|
||||
"pro.id,\n" +
|
||||
"info.product_name,\n" +
|
||||
"pro.is_stock,\n" +
|
||||
"info.product_sku_name,\n" +
|
||||
"unit.NAME;",nativeQuery = true)
|
||||
"info.product_sku_id;",nativeQuery = true)
|
||||
List<StockCountDTO> countStockById(Integer orderId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import javax.validation.constraints.NotNull;
|
|||
public interface TbPayService {
|
||||
void scanPay(ScanPayDTO scanPayDTO);
|
||||
|
||||
TbOrderInfo vipPay(@NotNull Integer shopId, @NotNull Integer orderId);
|
||||
TbOrderInfo vipPay(@NotNull Integer shopId, @NotNull Integer orderId, Double discount, Integer vipUserId);
|
||||
|
||||
TbOrderInfo cashPay(PayDTO payDTO);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ public interface TbVersionService {
|
|||
*/
|
||||
void update(TbVersion resources);
|
||||
|
||||
void updateSel(TbVersion resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
|
|
|
|||
|
|
@ -21,13 +21,14 @@ import cn.ysk.cashier.repository.shop.TbMerchantThirdApplyRepository;
|
|||
import cn.ysk.cashier.service.TbPayService;
|
||||
import cn.ysk.cashier.utils.RabbitMsgUtils;
|
||||
import cn.ysk.cashier.utils.SnowFlakeUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
|
@ -297,7 +298,7 @@ public class TbPayServiceImpl implements TbPayService {
|
|||
private final TbShopUserFlowMapper shopUserFlowMapper;
|
||||
|
||||
@Override
|
||||
public TbOrderInfo vipPay(@NotNull Integer shopId, @NotNull Integer orderId) {
|
||||
public TbOrderInfo vipPay(@NotNull Integer shopId, @NotNull Integer orderId, Double discount, Integer vipUserId) {
|
||||
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectById(orderId);
|
||||
|
||||
|
|
@ -309,6 +310,9 @@ public class TbPayServiceImpl implements TbPayService {
|
|||
throw new BadRequestException("订单非未支付状态");
|
||||
}
|
||||
|
||||
if (vipUserId != null) {
|
||||
orderInfo.setUserId(String.valueOf(vipUserId));
|
||||
}
|
||||
|
||||
// 扣减会员余额
|
||||
TbShopUser shopUser = shopUserMapper.selectOne(new LambdaUpdateWrapper<TbShopUser>()
|
||||
|
|
@ -319,22 +323,29 @@ public class TbPayServiceImpl implements TbPayService {
|
|||
throw new BadRequestException("用户不存在或已被禁用");
|
||||
}
|
||||
|
||||
long flag = shopUserMapper.decrBalance(Integer.valueOf(orderInfo.getUserId()), orderInfo.getOrderAmount());
|
||||
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);
|
||||
if (flag < 1) {
|
||||
throw new BadRequestException("余额不足或扣除余额失败");
|
||||
}
|
||||
|
||||
TbShopUserFlow userFlow = new TbShopUserFlow();
|
||||
userFlow.setAmount(orderInfo.getOrderAmount());
|
||||
userFlow.setAmount(payMount);
|
||||
userFlow.setBalance(shopUser.getAmount());
|
||||
userFlow.setShopUserId(shopUser.getId());
|
||||
userFlow.setBizCode("vipCardCash");
|
||||
userFlow.setBizName("代客下单会员余额支付");
|
||||
userFlow.setBizName("余额支付");
|
||||
userFlow.setCreateTime(DateUtil.date());
|
||||
userFlow.setType("-");
|
||||
shopUserFlowMapper.insert(userFlow);
|
||||
|
||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||
orderInfo.setPayAmount(payMount);
|
||||
if (discount != null && discount != 1) {
|
||||
orderInfo.setDiscountAmount(orderInfo.getOrderAmount().subtract(orderInfo.getPayAmount()));
|
||||
orderInfo.setDiscountRatio(BigDecimal.valueOf(discount));
|
||||
}
|
||||
|
||||
orderInfo.setPayType("cash");
|
||||
orderInfo.setStatus("closed");
|
||||
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
||||
|
|
@ -373,7 +384,12 @@ public class TbPayServiceImpl implements TbPayService {
|
|||
// return Result.fail(CodeEnum.PAYTYPENOEXIST);
|
||||
// }
|
||||
|
||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||
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()));
|
||||
}
|
||||
orderInfo.setPayType("cash");
|
||||
orderInfo.setStatus("closed");
|
||||
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
||||
|
|
|
|||
|
|
@ -7,10 +7,7 @@ import cn.ysk.cashier.mapper.TbVersionMapper;
|
|||
import cn.ysk.cashier.pojo.TbVersion;
|
||||
import cn.ysk.cashier.repository.TbVersionRepository;
|
||||
import cn.ysk.cashier.service.TbVersionService;
|
||||
import cn.ysk.cashier.utils.PageUtil;
|
||||
import cn.ysk.cashier.utils.QueryHelp;
|
||||
import cn.ysk.cashier.utils.RedisUtils;
|
||||
import cn.ysk.cashier.utils.ValidationUtil;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
|
@ -61,17 +58,17 @@ public class TbVersionServiceImpl implements TbVersionService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbVersionDto create(TbVersion resources) {
|
||||
int exist = tbVersionRepository.isExist(resources.getSource(), resources.getType(), resources.getVersion());
|
||||
int exist = tbVersionRepository.isExist(resources.getSource(), resources.getVersion());
|
||||
if (exist > 0) {
|
||||
throw new BadRequestException("该版本已存在。");
|
||||
}
|
||||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||
TbVersionDto dto = tbVersionMapper.toDto(tbVersionRepository.save(resources));
|
||||
if (dto.getIsUp() == 1) {
|
||||
//产品标识:型号:版本
|
||||
//LDBL_APP_VERSION:ios:version 存在即需要强制更新
|
||||
redisUtils.set(dto.getSource() + "_VERSION:" + dto.getType() + ":" + dto.getVersion(), dto.getMessage());
|
||||
}
|
||||
// if (dto.getIsUp() == 1) {
|
||||
// //产品标识:型号:版本
|
||||
// //VERSION:PC::version 存在即需要强制更新
|
||||
// redisUtils.set(CacheKey.VERSION + dto.getSource() + ":" + dto.getVersion(), dto);
|
||||
// }
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
|
@ -80,17 +77,23 @@ public class TbVersionServiceImpl implements TbVersionService {
|
|||
public void update(TbVersion resources) {
|
||||
TbVersion tbVersion = tbVersionRepository.findById(resources.getId()).orElseGet(TbVersion::new);
|
||||
ValidationUtil.isNull(tbVersion.getId(), "TbVersion", "id", resources.getId());
|
||||
redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
|
||||
// redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
|
||||
tbVersion.copy(resources);
|
||||
tbVersion.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
tbVersionRepository.save(tbVersion);
|
||||
if (resources.getIsUp() == 1) {
|
||||
//产品标识:型号:版本
|
||||
//LDBL_APP_VERSION:ios:version 存在即需要强制更新
|
||||
redisUtils.set(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion(), tbVersion.getMessage());
|
||||
} else {
|
||||
redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
|
||||
}
|
||||
// if (resources.getIsUp() == 1) {
|
||||
// //产品标识:型号:版本
|
||||
// //LDBL_APP_VERSION:ios:version 存在即需要强制更新
|
||||
// redisUtils.set(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion(), tbVersion.getMessage());
|
||||
// } else {
|
||||
// redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateSel(TbVersion resources) {
|
||||
tbVersionRepository.updateSelBySource(resources.getSource(),resources.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -99,9 +102,9 @@ public class TbVersionServiceImpl implements TbVersionService {
|
|||
TbVersion tbVersion = tbVersionRepository.findById(id).orElseGet(TbVersion::new);
|
||||
ValidationUtil.isNull(tbVersion.getId(), "TbVersion", "id", id);
|
||||
tbVersionRepository.deleteById(id);
|
||||
if (tbVersion.getIsUp() == 1) {
|
||||
redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
|
||||
}
|
||||
// if (tbVersion.getIsUp() == 1) {
|
||||
// redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -727,7 +727,7 @@ public class TbProductServiceImpl implements TbProductService {
|
|||
}
|
||||
|
||||
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbProduct> tbProductPage = productMapper.selectPage(page1, queryWrapper);
|
||||
tbProductPage.getRecords().stream().parallel().forEach(item -> {
|
||||
tbProductPage.getRecords().forEach(item -> {
|
||||
TbProductSkuResult skuResult = productSkuResultRepository.findById(item.getId()).orElse(null);
|
||||
List<TbProductSku> tbProductSkus = producSkutMapper.selectList(new LambdaQueryWrapper<TbProductSku>().eq(TbProductSku::getIsDel, 0)
|
||||
.eq(TbProductSku::getIsPauseSale, 0)
|
||||
|
|
@ -811,4 +811,8 @@ public class TbProductServiceImpl implements TbProductService {
|
|||
current.remove(current.size() - 1); // 回溯
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package cn.ysk.cashier.service.impl.productimpl;
|
|||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.dto.product.StockCountDTO;
|
||||
import cn.ysk.cashier.dto.rabbit.StockRecordMsg;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbProducSkutMapper;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.pojo.product.TbProductStockDetail;
|
||||
import cn.ysk.cashier.repository.order.StockCountRepository;
|
||||
|
|
@ -60,6 +60,7 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
|
|||
private final StockCountRepository stockCountRepository;
|
||||
private final EntityManager entityManager;
|
||||
private final TbOrderInfoRepository tbOrderInfoRepository;
|
||||
private final TbProducSkutMapper skutMapper;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -203,7 +204,7 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
|
|||
productStockDetail.setSubType(-1);
|
||||
tbProductStockDetailRepository.save(productStockDetail);
|
||||
}
|
||||
|
||||
skutMapper.incrRealSalesNumber(s.getSkuId().intValue(),s.getStockCount());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -330,6 +330,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
.eq(TbCashierCart::getMasterId, "");
|
||||
}));
|
||||
});
|
||||
|
||||
if (addCartDTO.getCartId() != null) {
|
||||
query.eq(TbCashierCart::getId, addCartDTO.getCartId());
|
||||
}
|
||||
|
||||
TbCashierCart tbCashierCart = cashierCartMapper.selectOne(query);
|
||||
// 首次加入
|
||||
if (tbCashierCart == null) {
|
||||
|
|
@ -901,19 +906,23 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
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);
|
||||
} else {
|
||||
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){
|
||||
String key = "SHOP:CODE:USER:pc" + ":" + createOrderDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 推送耗材信息
|
||||
pushConsMsg(orderInfo, cashierCarts);
|
||||
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getShopId, createOrderDTO.getShopId())
|
||||
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
|
||||
.set(TbShopTable::getStatus, TableStateEnum.USING.getState()));
|
||||
|
||||
|
|
@ -1020,6 +1029,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
|
||||
rabbitMsgUtils.printTicket(String.valueOf(orderId));
|
||||
}
|
||||
|
||||
return orderInfoMapper.selectById(orderId);
|
||||
}
|
||||
|
||||
|
|
@ -1078,7 +1088,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
TbOrderInfo orderInfo = null;
|
||||
switch (payDTO.getPayType()) {
|
||||
case "vipPay":
|
||||
orderInfo = tbPayServiceImpl.vipPay(payDTO.getShopId(), payDTO.getOrderId());
|
||||
orderInfo = tbPayServiceImpl.vipPay(payDTO.getShopId(), payDTO.getOrderId(), payDTO.getDiscount(), payDTO.getVipUserId());
|
||||
break;
|
||||
case "cash":
|
||||
orderInfo = tbPayServiceImpl.cashPay(payDTO);
|
||||
|
|
@ -1096,9 +1106,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
|
||||
// 打印消息
|
||||
rabbitMsgUtils.sendOrderCollectMsg(jsonObject);
|
||||
if (StrUtil.isBlank(orderInfo.getUseType()) || orderInfo.getUseType().equals("afterPay")) {
|
||||
rabbitMsgUtils.printTicket(String.valueOf(orderInfo.getId()));
|
||||
}
|
||||
rabbitMsgUtils.printTicket(String.valueOf(orderInfo.getId()));
|
||||
|
||||
// 发送库存记录mq消息
|
||||
JSONObject mqData = new JSONObject();
|
||||
|
|
|
|||
|
|
@ -73,10 +73,15 @@ public class TbShopUserServiceImpl implements TbShopUserService {
|
|||
shopUserInfoVo.setTotalScore(0);
|
||||
});
|
||||
}
|
||||
Integer orderNumber=tbOrderInfoRepository.countByUserIdAndStatusAndShopId(shopUserInfoVo.getId().toString(),criteria.getShopId());
|
||||
shopUserInfoVo.setOrderNumber(Objects.isNull(orderNumber)?0:orderNumber);
|
||||
shopUserInfoVo.setInMoney(tbShopUserRepository.sumAmount(shopUserInfoVo.getId()));
|
||||
|
||||
if (shopUserInfoVo.getUserId() == null) {
|
||||
shopUserInfoVo.setUserId(0);
|
||||
shopUserInfoVo.setOrderNumber(0);
|
||||
} else {
|
||||
Integer orderNumber = tbOrderInfoRepository.countByUserIdAndStatusAndShopId(shopUserInfoVo.getUserId().toString(), criteria.getShopId());
|
||||
shopUserInfoVo.setOrderNumber(Objects.isNull(orderNumber) ? 0 : orderNumber);
|
||||
}
|
||||
shopUserInfoVo.setInMoney(tbShopUserRepository.sumAmount(shopUserInfoVo.getId()));
|
||||
}
|
||||
|
||||
return PageUtil.toPlusPage(iPage.getRecords(), Integer.valueOf(iPage.getTotal() + ""));
|
||||
|
|
@ -194,51 +199,49 @@ public class TbShopUserServiceImpl implements TbShopUserService {
|
|||
|
||||
@Override
|
||||
public void modfiyAccount(Map<String, Object> map) {
|
||||
if(ObjectUtil.isNull(map)||ObjectUtil.isEmpty(map)||!map.containsKey("id")||!map.containsKey("type")||!map.containsKey("amount")
|
||||
||ObjectUtil.isEmpty(map.get("id"))||ObjectUtil.isNull(map.get("id"))||ObjectUtil.isNull(map.get("type"))||ObjectUtil.isEmpty(map.get("type"))
|
||||
||ObjectUtil.isEmpty(map.get("amount"))||ObjectUtil.isNull(map.get("amount"))||!map.containsKey("operationType")||ObjectUtil.isEmpty(map.get("operationType"))||ObjectUtil.isNull(map.get("operationType"))
|
||||
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("id") || !map.containsKey("type") || !map.containsKey("amount")
|
||||
|| ObjectUtil.isEmpty(map.get("id")) || ObjectUtil.isNull(map.get("id")) || ObjectUtil.isNull(map.get("type")) || ObjectUtil.isEmpty(map.get("type"))
|
||||
|| ObjectUtil.isEmpty(map.get("amount")) || ObjectUtil.isNull(map.get("amount")) || !map.containsKey("operationType") || ObjectUtil.isEmpty(map.get("operationType")) || ObjectUtil.isNull(map.get("operationType"))
|
||||
|
||||
){
|
||||
) {
|
||||
throw new BadRequestException("参数错误");
|
||||
|
||||
}
|
||||
|
||||
String regex = "^(([1-9][0-9]*)|(([0]\\.\\d{1,2}|[1-9][0-9]*\\.\\d{1,2})))$";
|
||||
if(!map.get("amount").toString().matches(regex)){
|
||||
if (!map.get("amount").toString().matches(regex)) {
|
||||
throw new BadRequestException("请输入正确的数字");
|
||||
}
|
||||
|
||||
|
||||
|
||||
TbShopUser tbShopUser= tbShopUserRepository.getById(Integer.valueOf(map.get("id")+""));
|
||||
if(ObjectUtil.isNull(tbShopUser)){
|
||||
throw new BadRequestException("不存在的会员信息");
|
||||
TbShopUser tbShopUser = tbShopUserRepository.getById(Integer.valueOf(map.get("id") + ""));
|
||||
if (ObjectUtil.isNull(tbShopUser)) {
|
||||
throw new BadRequestException("不存在的会员信息");
|
||||
}
|
||||
String operationType=map.get("operationType").toString();
|
||||
String operationType = map.get("operationType").toString();
|
||||
|
||||
BigDecimal amount=new BigDecimal(map.get("amount").toString());
|
||||
if("out".equals(operationType)){
|
||||
if(amount.compareTo(tbShopUser.getAmount())>0){
|
||||
BigDecimal amount = new BigDecimal(map.get("amount").toString());
|
||||
if ("out".equals(operationType)) {
|
||||
if (amount.compareTo(tbShopUser.getAmount()) > 0) {
|
||||
throw new BadRequestException("账户余额不足,请输入正确的金额");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String type = map.get("type").toString();
|
||||
TbShopUserFlow flow = new TbShopUserFlow();
|
||||
|
||||
String type=map.get("type").toString();
|
||||
TbShopUserFlow flow=new TbShopUserFlow();
|
||||
|
||||
if("in".equals(operationType)){
|
||||
if ("in".equals(operationType)) {
|
||||
flow.setType("+");
|
||||
flow.setBizName("inMoney".equals(type)?"充值":"消费退款");
|
||||
flow.setBizCode("inMoney".equals(type)?"inMoneyIn":"consumeIn");
|
||||
flow.setBizName("inMoney".equals(type) ? "充值" : "消费退款");
|
||||
flow.setBizCode("inMoney".equals(type) ? "inMoneyIn" : "consumeIn");
|
||||
tbShopUser.setAmount(tbShopUser.getAmount().add(amount));
|
||||
}else if("out".equals(operationType)){
|
||||
flow.setBizName("inMoney".equals(type)?"充值退款":"消费");
|
||||
flow.setBizCode("inMoney".equals(type)?"inMoneyOut":"consumeOut");
|
||||
} else if ("out".equals(operationType)) {
|
||||
flow.setBizName("inMoneyOut".equals(type) ? "充值退款" : "消费");
|
||||
flow.setBizCode("inMoneyOut".equals(type) ? "inMoneyOut" : "consumeOut");
|
||||
flow.setType("-");
|
||||
tbShopUser.setAmount(tbShopUser.getAmount().subtract(amount));
|
||||
}else {
|
||||
} else {
|
||||
throw new BadRequestException("错误的请求类型");
|
||||
}
|
||||
|
||||
|
|
@ -254,8 +257,6 @@ public class TbShopUserServiceImpl implements TbShopUserService {
|
|||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import java.math.BigDecimal;
|
|||
@Data
|
||||
public class ShopUserInfoVo implements Serializable {
|
||||
private Integer id;
|
||||
private Integer userId;
|
||||
private String headImg;
|
||||
private String nickName;
|
||||
private Object sex;
|
||||
|
|
|
|||
|
|
@ -1,73 +1,65 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="false" debug="false">
|
||||
|
||||
<!-- 日志存放路径, 读取application.yml 需要使用springProperty获取 -->
|
||||
<springProperty scope="context" name="currentLoggerFilePath" source="logging.file.path"/>
|
||||
|
||||
<!-- 主日志级别配置 -->
|
||||
<springProperty scope="context" name="currentRootLevel" source="logging.level.root"/>
|
||||
|
||||
<!-- 项目配置, 如修改包名,请搜索并全部替换掉 -->
|
||||
<springProperty scope="context" name="currentProjectLevel" source="logging.level.com.jeequan.jeepay"/>
|
||||
|
||||
<!-- 日志文件名称 logback属性 -->
|
||||
<property name="currentLoggerFileName" value="pay" />
|
||||
<!-- 日志格式, 参考:https://logback.qos.ch/manual/layouts.html -->
|
||||
<property name="currentLoggerPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] %logger{15} - %msg%n" />
|
||||
|
||||
<!-- appender: 控制台日志 -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder charset="UTF-8" >
|
||||
<pattern>${currentLoggerPattern}</pattern>
|
||||
<configuration scan="true" scanPeriod="30 seconds" debug="false">
|
||||
<contextName>elAdmin</contextName>
|
||||
<property name="log.charset" value="utf-8" />
|
||||
<property name="log.pattern" value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %msg%n" />
|
||||
<!--写入文件格式-->
|
||||
<property name="p_file" value="%d | [%thread] %-5level %c [%L] - %msg %n"/>
|
||||
<!--输出到控制台-->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
<charset>${log.charset}</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!--按天生成日志-->
|
||||
<appender name="logFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${user.dir}/logback.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!--生成日志文件名称-->
|
||||
<FileNamePattern>${user.dir}/logs/cashierAdmin/%d{yyyy-MM-dd}.log.gz</FileNamePattern>
|
||||
<!--日志文件保留天数-->
|
||||
<MaxHistory>15</MaxHistory>
|
||||
</rollingPolicy>
|
||||
<!-- 日志输出格式 -->
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>${p_file}</pattern>
|
||||
<charset>${log.charset}</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- appender:主日志文件 -->
|
||||
<appender name="ALL_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 日志文件路径及文件名 -->
|
||||
<file>${currentLoggerFilePath}/${currentLoggerFileName}.all.log</file>
|
||||
<!-- 内容编码及格式 -->
|
||||
<encoder charset="UTF-8" ><pattern>${currentLoggerPattern}</pattern></encoder>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 每天日志归档路径以及格式 -->
|
||||
<fileNamePattern>${currentLoggerFilePath}/${currentLoggerFileName}.all.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<maxHistory>5</maxHistory> <!--日志文件保留天数-->
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<!-- appender:错误信息日志文件 -->
|
||||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 日志文件路径及文件名 -->
|
||||
<file>${currentLoggerFilePath}/${currentLoggerFileName}.error.log</file>
|
||||
<!-- 内容编码及格式 -->
|
||||
<encoder charset="UTF-8" ><pattern>${currentLoggerPattern}</pattern></encoder>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 每天日志归档路径以及格式 -->
|
||||
<fileNamePattern>${currentLoggerFilePath}/${currentLoggerFileName}.error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<maxHistory>20</maxHistory> <!--日志文件保留天数-->
|
||||
</rollingPolicy>
|
||||
<!-- 此日志文件只记录ERROR级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 主日志级别配置 -->
|
||||
<root level="${currentRootLevel}">
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="ALL_FILE" />
|
||||
<appender-ref ref="ERROR_FILE" />
|
||||
<!--普通日志输出到控制台-->
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
<appender-ref ref="logFile"/>
|
||||
</root>
|
||||
|
||||
<!-- 项目日志级别配置 -->
|
||||
<logger name="cn.ysk.cashier" level="${currentProjectLevel}"/>
|
||||
<!--监控sql日志输出,如需监控 Sql 打印,请设置为 INFO -->
|
||||
<logger name="jdbc.sqlonly" level="ERROR" additivity="false">
|
||||
<appender-ref ref="console" />
|
||||
</logger>
|
||||
<logger name="org.hibernate.SQL" level="debug">
|
||||
|
||||
<logger name="org.apache.hc.client5.http.wire" level="info"/>
|
||||
</logger>
|
||||
|
||||
<logger name="org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager" level="info" />
|
||||
<logger name="jdbc.resultset" level="ERROR" additivity="false">
|
||||
<appender-ref ref="console" />
|
||||
</logger>
|
||||
|
||||
</configuration>
|
||||
<!-- 如想看到表格数据,将OFF改为INFO -->
|
||||
<logger name="jdbc.resultsettable" level="OFF" additivity="false">
|
||||
<appender-ref ref="console" />
|
||||
</logger>
|
||||
|
||||
<logger name="jdbc.connection" level="OFF" additivity="false">
|
||||
<appender-ref ref="console" />
|
||||
</logger>
|
||||
|
||||
<logger name="jdbc.sqltiming" level="OFF" additivity="false">
|
||||
<appender-ref ref="console" />
|
||||
</logger>
|
||||
|
||||
<logger name="jdbc.audit" level="OFF" additivity="false">
|
||||
<appender-ref ref="console" />
|
||||
</logger>
|
||||
</configuration>
|
||||
|
|
@ -77,7 +77,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,6 +89,15 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
// @Log("上传文件")
|
||||
@ApiOperation("上传文件")
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ public interface QiNiuService {
|
|||
*/
|
||||
List<QiniuContent> queryAll(QiniuQueryCriteria criteria);
|
||||
|
||||
String uploadVersionFile(MultipartFile file, CloudStorageConfig qiniuConfig,String fileName);
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param file 文件
|
||||
|
|
|
|||
|
|
@ -115,6 +115,22 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
return qiniuContentRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String uploadVersionFile(MultipartFile file, CloudStorageConfig qiniuConfig,String fileName) {
|
||||
if(qiniuConfig== null){
|
||||
throw new BadRequestException("请先添加相应配置,再操作");
|
||||
}
|
||||
// 构造一个带指定Zone对象的配置类
|
||||
try {
|
||||
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
||||
|
||||
return OSSFactory.build(qiniuConfig).uploadFileName(file.getBytes(), extension,fileName);
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public QiniuContent upload(MultipartFile file, CloudStorageConfig qiniuConfig) {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,25 @@ public abstract class AbstractCloudStorageService {
|
|||
return path + "." + suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
* @param prefix 前缀
|
||||
* @param fileName 文件名
|
||||
* @param suffix 后缀
|
||||
* @return 返回上传路径
|
||||
*/
|
||||
public String getPath(String prefix,String suffix, String fileName) {
|
||||
//文件路径
|
||||
// String path = DateUtils.getDays() + "/" + fileName;
|
||||
String path = "version/" + fileName;
|
||||
|
||||
if(StringUtils.isNotBlank(prefix)){
|
||||
path = prefix + "/" + path;
|
||||
}
|
||||
|
||||
return path + "." + suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
* @param data 文件字节数组
|
||||
|
|
@ -58,6 +77,7 @@ public abstract class AbstractCloudStorageService {
|
|||
* @return 返回http地址
|
||||
*/
|
||||
public abstract String uploadSuffix(byte[] data, String suffix) throws Exception;
|
||||
public abstract String uploadFileName(byte[] data, String suffix,String fileName) throws Exception;
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
|
|
|
|||
|
|
@ -49,6 +49,11 @@ public class AliyunCloudStorageService extends AbstractCloudStorageService {
|
|||
return upload(data, getPath(config.getPrefix(), suffix));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String uploadFileName(byte[] data, String suffix,String fileName) throws Exception {
|
||||
return upload(data, getPath(config.getPrefix(), suffix,fileName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String uploadSuffix(InputStream inputStream, String suffix) throws Exception {
|
||||
return upload(inputStream, getPath(config.getPrefix(), suffix));
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@ public class HuaweiCloudStorageService extends AbstractCloudStorageService {
|
|||
return config.getUrl() + "/" + path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String uploadFileName(byte[] data, String suffix,String fileName) throws Exception {
|
||||
return upload(data, getPath(config.getPrefix(), suffix,fileName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String uploadSuffix(InputStream inputStream, String suffix) throws Exception {
|
||||
return upload(inputStream, getPath(config.getPrefix(), suffix));
|
||||
|
|
|
|||
|
|
@ -82,4 +82,9 @@ public class QcloudCloudStorageService extends AbstractCloudStorageService {
|
|||
public String uploadSuffix(InputStream inputStream, String suffix) throws Exception {
|
||||
return upload(inputStream, getPath(config.getPrefix(), suffix));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String uploadFileName(byte[] data, String suffix,String fileName) throws Exception {
|
||||
return upload(data, getPath(config.getPrefix(), suffix,fileName));
|
||||
}
|
||||
}
|
||||
|
|
@ -75,4 +75,9 @@ public class QiniuCloudStorageService extends AbstractCloudStorageService {
|
|||
public String uploadSuffix(InputStream inputStream, String suffix) throws Exception {
|
||||
return upload(inputStream, getPath(config.getPrefix(), suffix));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String uploadFileName(byte[] data, String suffix,String fileName) throws Exception {
|
||||
return upload(data, getPath(config.getPrefix(), suffix,fileName));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue