diff --git a/eladmin-common/src/main/java/cn/ysk/cashier/utils/CacheKey.java b/eladmin-common/src/main/java/cn/ysk/cashier/utils/CacheKey.java index 78a39675..7773b32f 100644 --- a/eladmin-common/src/main/java/cn/ysk/cashier/utils/CacheKey.java +++ b/eladmin-common/src/main/java/cn/ysk/cashier/utils/CacheKey.java @@ -76,4 +76,6 @@ public interface CacheKey { String SONG_URL = "song:"; String VIPCODE = "VIPCODE:"; + + String INVOICE_SD_TYPE = "invoice:sd_type:"; } diff --git a/eladmin-common/src/main/java/cn/ysk/cashier/utils/ListUtil.java b/eladmin-common/src/main/java/cn/ysk/cashier/utils/ListUtil.java index ae821ec4..f42d52e4 100644 --- a/eladmin-common/src/main/java/cn/ysk/cashier/utils/ListUtil.java +++ b/eladmin-common/src/main/java/cn/ysk/cashier/utils/ListUtil.java @@ -102,10 +102,13 @@ public class ListUtil { } - public static String listChangeString(List listString){ - return listString.stream() - .map(Object::toString) - .collect(Collectors.joining(", ")); + public static String listToJsonString(List list) { + ObjectMapper objectMapper = new ObjectMapper(); + try { + return objectMapper.writeValueAsString(list); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } } public static String mapToString(Map map) { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java index 0865bed7..43d1eb96 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java @@ -5,11 +5,19 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.config.security.config.bean.LoginCodeEnum; import cn.ysk.cashier.config.security.security.TokenProvider; +import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper; +import cn.ysk.cashier.mybatis.mapper.TbMerchantAccountMapper; +import cn.ysk.cashier.mybatis.service.MpShopUserService; +import cn.ysk.cashier.pojo.TbToken; import cn.ysk.cashier.pojo.shop.TbMerchantAccount; import cn.ysk.cashier.pojo.shop.TbPlussShopStaff; +import cn.ysk.cashier.repository.TbTokenRepository; import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository; import cn.ysk.cashier.repository.shop.TbPlussShopStaffRepository; import cn.ysk.cashier.utils.*; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.wf.captcha.base.Captcha; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -43,6 +51,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -66,6 +75,11 @@ public class AuthorizationController { private final TbShopInfoRepository tbShopInfoRepository; private final TbPlussShopStaffRepository staffRepository; private final TbMerchantAccountRepository tbMerchantAccountRepository; + private final TbMerchantAccountMapper tbMerchantAccountMapper; + private final TbTokenRepository tbTokenRepository; + private final MpShopUserService shopUserService; + private final MpShopInfoMapper shopInfoMapper; + @Resource private LoginProperties loginProperties; @@ -137,6 +151,7 @@ public class AuthorizationController { put("user", jwtUserDto); if (byAccount != null) { put("shopId", byAccount.getId()); + put("mainId", org.apache.commons.lang3.StringUtils.isNotBlank(byAccount.getMainId())?byAccount.getMainId():byAccount.getId()); put("loginType", org.apache.commons.lang3.StringUtils.isNotBlank(authUser.getLoginType())?authUser.getLoginType():"merchant"); put("shopName", byAccount.getShopName()); put("logo", byAccount.getLogo()); @@ -153,6 +168,33 @@ public class AuthorizationController { return ResponseEntity.ok(authInfo); } + + @GetMapping("/userInfo") + public ResponseEntity getUserInfo(HttpServletRequest request) { + String token = tokenProvider.getToken(request); + JSONObject userInfo = JSON.parseObject(JSON.toJSONString(redisUtils.get("online-token-" + token))); + String userName = userInfo.getString("userName"); + String shopId = userInfo.getString("shopId"); + TbShopInfo shopInfo = shopInfoMapper.selectById(shopId); + TbPlussShopStaff shopStaff; + if (userName.contains("@")) { + shopStaff = staffRepository.queryMasterAccount(shopId); + } else { + shopStaff = staffRepository.queryByAccount(userName, shopId); + } +// TbMerchantAccount merchantAccount = tbMerchantAccountMapper.selectOne(Wrappers.lambdaQuery() +// .eq(TbMerchantAccount::getAccount, shopStaff.getAccount())); +// Integer accountId = merchantAccount.getId(); +// Integer staffId = shopStaff.getId(); +// List onlineUserList = tbTokenRepository.findListByAccountIdAndStaffId(accountId, staffId); + shopStaff.setPassword(null); + return ResponseEntity.ok(new HashMap(){{ + put("shopInfo", shopInfo); + put("shopStaff", shopStaff); + }}); + } + + /** * 小程序登录 * diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/security/TokenProvider.java b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/security/TokenProvider.java index d66bd65c..a035a0e2 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/security/TokenProvider.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/security/TokenProvider.java @@ -73,6 +73,16 @@ public class TokenProvider implements InitializingBean { .compact(); } + public String createToken(String name,String shopId) { + return jwtBuilder + // 加入ID确保生成的 Token 都不一致 + .setId(IdUtil.simpleUUID()) + .claim(AUTHORITIES_KEY, name) + .claim("shopId",shopId) + .setSubject(name) + .compact(); + } + /** * 依据Token 获取鉴权信息 * diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/service/OnlineUserService.java b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/service/OnlineUserService.java index 360d2df2..450968dc 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/service/OnlineUserService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/service/OnlineUserService.java @@ -50,6 +50,19 @@ public class OnlineUserService { redisUtils.set(properties.getOnlineKey() + token, onlineUserDto, properties.getTokenValidityInSeconds()/1000); } + public void save(String username, String nickName, String token, HttpServletRequest request,Integer shopId){ + String ip = StringUtils.getIp(request); + String browser = StringUtils.getBrowser(request); + String address = StringUtils.getCityInfo(ip); + OnlineUserDto onlineUserDto = null; + try { + onlineUserDto = new OnlineUserDto(shopId,username, nickName, null, browser , ip, address, EncryptUtils.desEncrypt(token), new Date()); + } catch (Exception e) { + log.error(e.getMessage(),e); + } + redisUtils.set(properties.getOnlineKey() + token, onlineUserDto, properties.getTokenValidityInSeconds()/1000); + } + /** * 查询全部数据 * @param filter / diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java index 1244125a..af3557f0 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java @@ -20,6 +20,35 @@ public interface TableConstant { } } + class Product { + @Getter + public enum Type { + NORMAL("normal"), PACKAGE("package"); + private final String value; + + Type(String value) { + this.value = value; + } + + public boolean equalsVals(String value) { + return this.value.equals(value); + } + + } + } + + class ThirdPartyCoupon { + @Getter + public enum Plat { + MEI_TUAN("meituan"); + private final String value; + + Plat(String value) { + this.value = value; + } + } + } + class CashierCart { public static final String ID = "-999"; @@ -70,6 +99,35 @@ public interface TableConstant { } + @Getter + public enum OrderType { + COUPON("coupon"); + private final String value; + + OrderType(String value) { + this.value = value; + } + + public boolean equalsVals(String value) { + return this.value.equals(value); + } + + } + + @Getter + public enum PayType { + CREDIT_BUYER("creditBuyer"); + private final String value; + + PayType(String value) { + this.value = value; + } + public boolean equalsVals(String value) { + return this.value.equals(value); + } + } + + @Getter public enum UseType { TAKEOUT("takeout"), diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/SuppFlow.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/SuppFlow.java index 3baa92e7..dbd4aa54 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/SuppFlow.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/SuppFlow.java @@ -30,6 +30,7 @@ public class SuppFlow implements Serializable { @Data public static class ConInfos{ private Integer conInfoId; + private String name; private String unit; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsInfoRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsInfoRepository.java index 5b7c1a93..bf9c29f5 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsInfoRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsInfoRepository.java @@ -6,6 +6,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; 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; import java.util.List; @@ -34,4 +35,15 @@ public interface TbConsInfoRepository extends JpaRepository " where conPro.con_info_id = :conInfoId " + " group by conPro.product_id ",nativeQuery = true) List> queryAllAndPro(@Param("shopId") Integer shopId, @Param("conInfoId")Integer conInfoId); + + @Query(value = + "SELECT *" + + " FROM" + + " tb_cons_info conPro" + + " where conPro.shop_id = :shopId ",nativeQuery = true) + List searchConsInfoByShopId(Integer shopId); + + @Modifying + @Query(value = "delete FROM tb_prosku_con conPro where conPro.shop_id = :shopId ",nativeQuery = true) + void clearShopCons(Integer shopId); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsTypeRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsTypeRepository.java index 25b7904d..754358a1 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsTypeRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbConsTypeRepository.java @@ -3,8 +3,11 @@ package cn.ysk.cashier.cons.repository; import cn.ysk.cashier.cons.domain.TbConsType; 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; +import java.util.List; + /** * @website https://eladmin.vip * @author admin @@ -16,6 +19,13 @@ public interface TbConsTypeRepository extends JpaRepository TbConsType findByConTypeCode(String conTypeCode); + @Query("SELECT c FROM TbConsType c WHERE c.shopId = :shopId") + List searchConsTypeByShopId(Integer shopId); + + @Modifying + @Query("delete FROM TbProskuCon c WHERE c.shopId = :shopId") + void clearShopConType(Integer shopId); + @Query("SELECT count(*) FROM TbProskuCon c LEFT JOIN TbConsInfo i ON c.conInfoId = i.id WHERE i.conTypeId = :id") int countProByTypeId(Integer id); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java index e16d6305..0b020ef9 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/repository/TbProskuConRepository.java @@ -30,4 +30,11 @@ public interface TbProskuConRepository extends JpaRepository searchAllByProductId(Integer productId); + @Query(value = "select * from tb_prosku_con where shop_id=?1 ",nativeQuery = true) + List searchConsProByShopId(Integer shopId); + + @Modifying + @Query(value = "delete from tb_prosku_con where shop_id = :shopId",nativeQuery = true) + void clearShopConPro(Integer shopId); + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java index 21b6ba85..67fcd93e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConCheckServiceImpl.java @@ -113,7 +113,6 @@ public class TbConCheckServiceImpl implements TbConCheckService { conCheck.setPrice(consInfo.getPrice()); conCheck.setAcStockNumber(resources.getStockNumber()); conCheck.setStockNumber(resources.getStockNumber()); - conCheck.setLpNum(resources.getLpNum()); conCheck.setLpAmount(consInfo.getPrice().multiply(resources.getLpNum())); conCheck.setLpNum(resources.getLpNum()); conCheck.setCreateTime(new Timestamp(System.currentTimeMillis())); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java index 476203f3..423171c7 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java @@ -67,7 +67,6 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { private final TbProductStockOperateRepository tbProductStockOperateRepository; - @Override public Map queryAll(TbConsInfoQueryCriteria criteria, Pageable pageable) { Page page = tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); @@ -77,7 +76,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { @Override public Map queryAllAndPro(TbConsInfoQueryCriteria criteria) { Sort sort = Sort.by(Sort.Direction.DESC, "id"); - if(StringUtils.isNotBlank(criteria.getSort())){ + if (StringUtils.isNotBlank(criteria.getSort())) { String[] sortParams = criteria.getSort().split(","); String sortField = sortParams[0]; Sort.Direction sortDirection = Sort.Direction.fromString(sortParams[1]); @@ -112,7 +111,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { @Override @Transactional(rollbackFor = Exception.class) - public TbConsInfoDto create(List resources){ + public TbConsInfoDto create(List resources) { for (TbConsInfo resource : resources) { @@ -125,8 +124,8 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { // if (count > 0) { // throw new Exception("耗材代码不允许重复"); // } - if(StringUtils.isBlank(resource.getConUnit())){ - throw new BadRequestException(resource.getConName()+ "的单位不允许为空"); + if (StringUtils.isBlank(resource.getConUnit())) { + throw new BadRequestException(resource.getConName() + "的单位不允许为空"); } resource.setConCode(StringCodeUtil.getRandom(8, LETTER_CAPITAL_NUMBER)); resource.setConTypeName(tbConsType.getConTypeName()); @@ -150,7 +149,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { if (Objects.isNull(tbConsInfo)) { throw new Exception("耗材信息不存在"); } - BeanUtil.copyProperties(resource,tbConsInfo, CopyOptions.create().setIgnoreNullValue(true)); + BeanUtil.copyProperties(resource, tbConsInfo, CopyOptions.create().setIgnoreNullValue(true)); tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis())); tbConsInfoRepository.save(tbConsInfo); } @@ -220,7 +219,6 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { JSONArray array = new JSONArray(); - for (SuppFlow.ConInfos conInfos : resources.getList()) { JSONObject object = new JSONObject(); @@ -229,34 +227,29 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { log.info("耗材信息不存在"); continue; } + conInfos.setName(info.getConName()); BigDecimal changeStock = conInfos.getStockNumber(); //副单位的实际修改值 if (StringUtils.isNotBlank(conInfos.getUnit())) { info.setDefaultUnit(conInfos.getUnit()); + conInfos.setUnit(conInfos.getUnit()); if (conInfos.getUnit().equals(info.getConUnitTwo())) { changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP); } - } else if (StringUtils.isNotBlank(info.getConUnitTwo()) - && StringUtils.isNotBlank(info.getDefaultUnit()) - && info.getConUnitTwo().equals(info.getDefaultUnit())) { - info.setDefaultUnit(info.getConUnitTwo()); - changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP); + } else if(StringUtils.isNotBlank(info.getDefaultUnit())){ + info.setDefaultUnit(info.getDefaultUnit()); + conInfos.setUnit(info.getDefaultUnit()); + if(StringUtils.isNotBlank(info.getConUnitTwo())&& info.getConUnitTwo().equals(info.getDefaultUnit())){ + changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP); + } + } else { + info.setDefaultUnit(info.getConUnit()); + conInfos.setUnit(info.getConUnit()); } - - TbConsSuppFlow suppFlow = new TbConsSuppFlow(); TbConsInfoFlow flow = new TbConsInfoFlow(); - - TbShopPurveyorTransact purveyorTransact = new TbShopPurveyorTransact(); - purveyorTransact.setShopId(tbShopInfo.getId().toString()); - purveyorTransact.setPurveyorName(Objects.isNull(purveyor) ? "" : purveyor.getPurveyorName()); - purveyorTransact.setPurveyorId(Objects.isNull(purveyor) ? "" : purveyor.getId().toString()); - purveyorTransact.setRemark(resources.getRemark()); - purveyorTransact.setCreatedAt(System.currentTimeMillis()); - purveyorTransact.setUpdatedAt(System.currentTimeMillis()); - suppFlow.setConInfoId(info.getConTypeId()); suppFlow.setShopId(resources.getShopId()); suppFlow.setSupplierId(Objects.isNull(resources.getSupplierId()) ? 0 : resources.getSupplierId()); @@ -265,27 +258,17 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { //实际库存 BigDecimal amount = info.getStockNumber().subtract(info.getStockConsume()); - if ("in".equals(resources.getType())) { stockOperate.setSubType(1); info.setStockNumber(info.getStockNumber().add(changeStock)); info.setLasterInStock(changeStock); - suppFlow.setBalance(info.getStockNumber().subtract(info.getStockConsume()).add(changeStock)); - - flow.setBizCode("stockIn"); flow.setBizName("耗材入库"); flow.setBizType("+"); - purveyorTransact.setTotalAmount(resources.getAccountsPayable()); - purveyorTransact.setPaidAmount(resources.getActualPayment()); - purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment()))); - purveyorTransact.setType("cons_in"); - object.put("number", changeStock); - } - else if ("out".equals(resources.getType())) { + } else if ("out".equals(resources.getType())) { stockOperate.setSubType(-1); if (changeStock.compareTo(amount) > 0) { @@ -293,23 +276,12 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { } info.setStockNumber(info.getStockNumber().subtract(changeStock)); - - suppFlow.setBalance(info.getStockNumber().subtract(info.getStockConsume()).subtract(changeStock)); - - flow.setBizCode("stockout"); flow.setBizName("耗材出库"); flow.setBizType("-"); - - purveyorTransact.setPaidAmount(resources.getActualPayment()); - purveyorTransact.setTotalAmount(resources.getAccountsPayable().negate()); - - purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())).negate()); - purveyorTransact.setType("cons_out"); object.put("number", changeStock); - } - else { + } else { throw new BadRequestException("错误操作类型"); } @@ -326,21 +298,6 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { suppFlow.setActualPayment(resources.getActualPayment()); suppFlow.setCreateTime(new Timestamp(System.currentTimeMillis())); - - if (resources.getAccountsPayable().compareTo(resources.getActualPayment()) <= 0) { - purveyorTransact.setStatus(1); - } else { - purveyorTransact.setStatus(0); - } - - purveyorTransact.setPaidAt(System.currentTimeMillis()); - //供应商 - purveyorTransactRepository.save(purveyorTransact); - if (resources.getSupplierId() != null) { - tbShopPurveyorRepository.upLastTransactAt(resources.getSupplierId().toString()); - } - - tbConsInfoRepository.save(info); tbConsSuppFlowRepository.save(suppFlow); @@ -359,6 +316,39 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { stockOperate.setBatchNumber(""); stockOperate.setStockSnap(array.toJSONString()); tbProductStockOperateRepository.save(stockOperate); + + if (resources.getSupplierId() != null) { + TbShopPurveyorTransact purveyorTransact = new TbShopPurveyorTransact(); + purveyorTransact.setShopId(tbShopInfo.getId().toString()); + purveyorTransact.setPurveyorName(Objects.isNull(purveyor) ? "" : purveyor.getPurveyorName()); + purveyorTransact.setPurveyorId(Objects.isNull(purveyor) ? "" : purveyor.getId().toString()); + purveyorTransact.setRemark(resources.getRemark()); + purveyorTransact.setCreatedAt(System.currentTimeMillis()); + purveyorTransact.setUpdatedAt(System.currentTimeMillis()); + purveyorTransact.setPaidAt(System.currentTimeMillis()); + purveyorTransact.setConInfos(JSONUtil.toJSONString(resources.getList())); + if ("in".equals(resources.getType())) { + purveyorTransact.setTotalAmount(resources.getAccountsPayable()); + purveyorTransact.setPaidAmount(resources.getActualPayment()); + purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment()))); + purveyorTransact.setType("cons_in"); + } else if ("out".equals(resources.getType())) { + purveyorTransact.setPaidAmount(resources.getActualPayment()); + purveyorTransact.setTotalAmount(resources.getAccountsPayable().negate()); + + purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())).negate()); + purveyorTransact.setType("cons_out"); + } + + if (resources.getAccountsPayable().compareTo(resources.getActualPayment()) <= 0) { + purveyorTransact.setStatus(1); + } else { + purveyorTransact.setStatus(0); + } + //供应商 + purveyorTransactRepository.save(purveyorTransact); + tbShopPurveyorRepository.upLastTransactAt(resources.getSupplierId().toString()); + } } @Override diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopShareController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopShareController.java index 40ffba36..e3d707e2 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopShareController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopShareController.java @@ -36,7 +36,6 @@ public class TbShopShareController { private TbShopShareRecordService tbShopShareRecordService; @PostMapping("byShare") - @AnonymousPostMapping @ApiOperation("分页查询") public ResponseEntity selectAllByShare(@RequestBody TbShopShareRecordQueryCriteria criteria) { return new ResponseEntity<>(tbShopShareRecordService.selectAllByShare(criteria), HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java new file mode 100644 index 00000000..403538e6 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopSyncInfoController.java @@ -0,0 +1,76 @@ +package cn.ysk.cashier.controller; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; +import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; +import cn.ysk.cashier.dto.TbShopSyncInfoQueryCriteria; +import cn.ysk.cashier.mybatis.entity.TbShopSyncInfo; +import cn.ysk.cashier.mybatis.mapper.TbShopSyncInfoMapper; +import cn.ysk.cashier.mybatis.service.TbShopSyncInfoService; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Date; + +/** + * 店铺信息同步记录表(TbShopSyncInfo)表控制层 + * + * @author ww + * @since 2024-11-25 16:46:12 + */ +@RestController +@RequestMapping("/api/tbShopSyncInfo") +public class TbShopSyncInfoController { + + @Resource + private TbShopSyncInfoService tbShopSyncInfoService; + + @Autowired + private TbShopSyncInfoMapper tbShopSyncInfomapper; + + @GetMapping + @ApiOperation("查询同步数据情况") + public ResponseEntity selectAll(TbShopSyncInfoQueryCriteria criteria) { + return new ResponseEntity<>(tbShopSyncInfoService.queryByShopId(criteria), HttpStatus.OK); + } + + @PostMapping("/sync") + @ApiOperation("同步") + public ResponseEntity sync(@RequestBody TbShopSyncInfo tbShopSyncInfo) { + TbShopSyncInfoQueryCriteria criteria = new TbShopSyncInfoQueryCriteria(); + criteria.setPointShopId(tbShopSyncInfo.getPointShopId()); + TbShopSyncInfo tbShopSyncInfo1 = tbShopSyncInfoService.queryByShopId(criteria); + if (tbShopSyncInfo1 != null) { + throw new RuntimeException("已同步 请勿重复操作"); + } + tbShopSyncInfo.setSyncTime(new Date()); + tbShopSyncInfo.setStatus(1); + tbShopSyncInfomapper.insert(tbShopSyncInfo); + tbShopSyncInfoService.sync(tbShopSyncInfo); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + @AnonymousPostMapping("/clear") + @ApiOperation("一键清除店铺数据") + public ResponseEntity clear(@RequestBody TbShopSyncInfo tbShopSyncInfo){ + TbShopSyncInfoQueryCriteria criteria = new TbShopSyncInfoQueryCriteria(); + criteria.setPointShopId(tbShopSyncInfo.getPointShopId()); + TbShopSyncInfo tbShopSyncInfo1 = tbShopSyncInfoService.queryByShopId(criteria); + if(tbShopSyncInfo1 != null){ + long between = DateUtil.between(new Date(), tbShopSyncInfo1.getSyncTime(), DateUnit.HOUR); + if(between > 24){ + throw new RuntimeException("数据同步已超过一天 无法清除"); + } + tbShopSyncInfoService.clear(tbShopSyncInfo); + } + return new ResponseEntity<>(HttpStatus.OK); + } + + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java new file mode 100644 index 00000000..7714c0e8 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/ThirdPartyCouponController.java @@ -0,0 +1,77 @@ +package cn.ysk.cashier.controller; + +import cn.ysk.cashier.dto.thirdcoupon.BaseQueryDTO; +import cn.ysk.cashier.dto.thirdcoupon.CheckCouponDTO; +import cn.ysk.cashier.service.ThirdPartyCouponService; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * 三方团购券 + */ +@RestController +@RequestMapping("/api/thirdPartyCoupon") +public class ThirdPartyCouponController { + + private final ThirdPartyCouponService thirdPartyCouponService; + + public ThirdPartyCouponController(ThirdPartyCouponService thirdPartyCouponService) { + this.thirdPartyCouponService = thirdPartyCouponService; + } + + /** + * 获取绑定状态 + * @return 绑定状态 + */ + @GetMapping("/state") + public ResponseEntity> getState(@RequestParam Integer shopId) { + return ResponseEntity.ok(thirdPartyCouponService.getState(shopId)); + } + + /** + * 获取美团绑定链接 + * @return 美团绑定链接 + */ + @GetMapping("bindUrl") + public ResponseEntity getBindUrl(@RequestParam Integer shopId) { + return ResponseEntity.ok(thirdPartyCouponService.getBindUrl(shopId)); + } + + /** + * 解绑美团商家 + * @return 美团解绑链接 + */ + @GetMapping("unBindUrl") + public ResponseEntity getUnBindUrl(@RequestParam Integer shopId) { + return ResponseEntity.ok(thirdPartyCouponService.getUnBindUrl(shopId)); + } + + /** + * 获取门店客核销券 + * @return 所有券 + */ + @GetMapping("list") + public ResponseEntity> getActivateCoupon(@RequestParam Integer shopId, @RequestParam String code) { + return ResponseEntity.ok(thirdPartyCouponService.getActivateCoupon(shopId, code)); + } + + /** + * 核销券 + */ + @PostMapping + public ResponseEntity> checkCoupon(@RequestBody CheckCouponDTO checkCouponDTO) { + return ResponseEntity.ok(thirdPartyCouponService.checkCoupon(checkCouponDTO)); + } + + /** + * 撤销券核销 + */ + @DeleteMapping("revoke") + public ResponseEntity> revokeCoupon(@RequestBody CheckCouponDTO checkCouponDTO) { + return ResponseEntity.ok(thirdPartyCouponService.revokeCoupon(checkCouponDTO)); + } + + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java new file mode 100644 index 00000000..ed245d21 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/booking/TbShopTableBookingController.java @@ -0,0 +1,110 @@ +package cn.ysk.cashier.controller.booking; + +import cn.hutool.core.convert.Convert; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.map.MapUtil; +import cn.ysk.cashier.dto.booking.ShopTableBookingDTO; +import cn.ysk.cashier.mybatis.entity.TbShopTableBooking; +import cn.ysk.cashier.mybatis.service.TbShopTableBookingService; +import cn.ysk.cashier.pojo.shop.TbShopArea; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * 店铺台桌预订 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-21 + */ +@RestController +@RequestMapping("/api/booking/shop-table") +@Api(tags = "店铺台桌预订") +public class TbShopTableBookingController { + + @Resource + private TbShopTableBookingService tbShopTableBookingService; + + @GetMapping("page") + @ApiOperation("分页") + public ResponseEntity page(@RequestParam Map params) { + Map data = tbShopTableBookingService.page(params); + return ResponseEntity.ok().body(data); + } + + @GetMapping("{id}") + @ApiOperation("信息") + public ResponseEntity get(@PathVariable("id") Long id) { + TbShopTableBooking data = tbShopTableBookingService.getById(id); + return ResponseEntity.ok().body(data); + } + + @PostMapping + @ApiOperation("预订") + public ResponseEntity booking(@RequestBody TbShopTableBooking dto) { + String orderNo = tbShopTableBookingService.booking(dto); + Map data = new HashMap<>(2); + data.put("id", dto.getId()); + data.put("orderNo", orderNo); + return ResponseEntity.ok().body(data); + } + + @PutMapping + @ApiOperation("修改预订信息") + public ResponseEntity update(@RequestBody TbShopTableBooking dto) { + boolean ret = tbShopTableBookingService.update(dto); + return ResponseEntity.ok().body(ret); + } + + @PostMapping("mark-status") + @ApiOperation("修改预订状态") + public ResponseEntity markStatus(@RequestBody TbShopTableBooking dto) { + tbShopTableBookingService.markStatus(dto.getId(), dto.getStatus()); + return ResponseEntity.ok().build(); + } + + @DeleteMapping("/delete/{id}") + @ApiOperation("删除") + public ResponseEntity delete(@PathVariable("id") Long id) { + tbShopTableBookingService.delete(id); + return ResponseEntity.ok().build(); + } + + @GetMapping("sms") + @ApiOperation("获取待发送的短信内容") + public ResponseEntity sms(@RequestParam("shopId") Integer shopId) { + String smsContent = tbShopTableBookingService.getBookingSms(shopId); + return ResponseEntity.ok().body(smsContent); + } + + @GetMapping("area") + @ApiOperation("获取区域列表") + public ResponseEntity areaList(@RequestParam Integer shopId) { + List list = tbShopTableBookingService.findShopAreaList(shopId); + return ResponseEntity.ok().body(list); + } + + @GetMapping("list") + @ApiOperation("获取台桌列表") + public ResponseEntity list(@RequestParam Map params) { + List list = tbShopTableBookingService.findShopTableList(params); + return ResponseEntity.ok().body(list); + } + + @PostMapping("summary") + @ApiOperation("根据电话号码统计历史预订信息") + public ResponseEntity summary(@RequestBody Map params) { + MapProxy proxy = MapUtil.createProxy(params); + Integer shopId = proxy.getInt("shopId"); + String[] phoneNos = Convert.toStrArray(proxy.get("phoneNos")); + Map data = tbShopTableBookingService.summary(shopId, phoneNos); + return ResponseEntity.ok().body(data); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerController.java new file mode 100644 index 00000000..3a8439c9 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerController.java @@ -0,0 +1,70 @@ +package cn.ysk.cashier.controller.credit; + +import cn.ysk.cashier.mybatis.entity.TbCreditBuyer; +import cn.ysk.cashier.mybatis.service.TbCreditBuyerService; +import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Map; + + +/** +* 挂账人 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-11-20 +*/ +@RestController +@RequestMapping("/api/credit/buyer") +@Tag(name = "挂账人") +public class TbCreditBuyerController { + + @Resource + private TbCreditBuyerService tbCreditBuyerService; + + @GetMapping("page") + @ApiOperation("分页") + public ResponseEntity page(@RequestParam Map params){ + Map page = tbCreditBuyerService.page(params); + return ResponseEntity.ok().body(page); + } + + + @GetMapping("{id}") + @ApiOperation("信息") + public ResponseEntity get(@PathVariable("id") String id){ + TbCreditBuyer data = tbCreditBuyerService.getById(id); + return ResponseEntity.ok().body(data); + } + + @PostMapping + @ApiOperation("保存") + public ResponseEntity save(@RequestBody TbCreditBuyer entity){ + boolean ret = tbCreditBuyerService.save(entity); + return ResponseEntity.ok().body(ret); + } + + @PutMapping + @ApiOperation("修改") + public ResponseEntity update(@RequestBody TbCreditBuyer dto){ + boolean ret = tbCreditBuyerService.update(dto); + return ResponseEntity.ok().body(ret); + } + + @DeleteMapping("{id}") + @ApiOperation("删除") + public ResponseEntity delete(@PathVariable("id") String id){ + tbCreditBuyerService.delete(id); + return ResponseEntity.ok().build(); + } + + @PostMapping("repayment") + @ApiOperation("还款") + public ResponseEntity repayment(@RequestBody Map params) { + Map data = tbCreditBuyerService.repayment(params); + return ResponseEntity.ok().body(data); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerOrderController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerOrderController.java new file mode 100644 index 00000000..9ca18496 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditBuyerOrderController.java @@ -0,0 +1,48 @@ +package cn.ysk.cashier.controller.credit; + +import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; +import cn.ysk.cashier.mybatis.service.TbCreditBuyerOrderService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Map; + + +/** + * 挂账账单 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@RestController +@RequestMapping("/api/credit/buyer-order") +@Api(tags = "挂账账单") +public class TbCreditBuyerOrderController { + + @Resource + private TbCreditBuyerOrderService tbCreditBuyerOrderService; + + @GetMapping("page") + @ApiOperation("分页") + public ResponseEntity page(@RequestParam Map params) { + Map page = tbCreditBuyerOrderService.page(params); + return ResponseEntity.ok().body(page); + } + + @PostMapping("pay") + @ApiOperation("付款") + public ResponseEntity pay(@RequestBody TbCreditPaymentRecord record) { + tbCreditBuyerOrderService.pay(record); + return ResponseEntity.ok().build(); + } + + @GetMapping("summary") + @ApiOperation("统计") + public ResponseEntity summary(@RequestParam Map params) { + Map data = tbCreditBuyerOrderService.summary(params); + return ResponseEntity.ok().body(data); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditPaymentRecordController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditPaymentRecordController.java new file mode 100644 index 00000000..ef5db472 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/credit/TbCreditPaymentRecordController.java @@ -0,0 +1,37 @@ +package cn.ysk.cashier.controller.credit; + +import cn.ysk.cashier.mybatis.service.TbCreditPaymentRecordService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.Map; + + +/** +* 挂账账单付款记录 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-11-20 +*/ +@RestController +@RequestMapping("/api/credit/payment-record") +@Api(tags = "挂账账单付款记录") +public class TbCreditPaymentRecordController { + + @Resource + private TbCreditPaymentRecordService tbCreditPaymentRecordService; + + @GetMapping("page") + @ApiOperation("分页") + public ResponseEntity page(@RequestParam Map params){ + Map page = tbCreditPaymentRecordService.page(params); + return ResponseEntity.ok().body(page); + } + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java index bf4bf30c..3caed88d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java @@ -3,6 +3,7 @@ package cn.ysk.cashier.controller.product; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.annotation.AnonymousAccess; +import cn.ysk.cashier.annotation.Limit; import cn.ysk.cashier.annotation.Log; import cn.ysk.cashier.config.security.security.TokenProvider; import cn.ysk.cashier.dto.shoptable.*; @@ -18,6 +19,7 @@ import cn.ysk.cashier.service.product.TbProductService; import cn.ysk.cashier.service.shop.TbShopTableService; import cn.ysk.cashier.utils.RabbitMsgUtils; import cn.ysk.cashier.utils.RedisUtils; +import cn.ysk.cashier.utils.Utils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -77,11 +79,15 @@ public class TbPlaceController { } @PostMapping("/temporaryDishes") - @ApiOperation("代客下单/shop/table") public ResponseEntity addTemporaryDishes(@Valid @RequestBody AddTemporaryDishesDTO temporaryDishesDTO) { return ResponseEntity.ok(tbShopTableService.addTemporaryDishes(temporaryDishesDTO)); } + @PutMapping("/updatePrice") + public ResponseEntity updatePrice(@Valid @RequestBody UpdatePriceDTO updatePriceDTO) { + return ResponseEntity.ok(tbShopTableService.updatePrice(updatePriceDTO)); + } + @PutMapping("/choseModel") @ApiOperation("代客下单/shop/table") public ResponseEntity choseModel(@Valid @RequestBody ChoseModelDTO choseModelDTO) { @@ -152,7 +158,8 @@ public class TbPlaceController { @PostMapping("/order") @ApiOperation("代客下单 查询购物车 /shop/table") - public ResponseEntity createOrder(@RequestBody CreateOrderDTO createOrderDTO) { + public ResponseEntity createOrder(HttpServletRequest request, @RequestBody CreateOrderDTO createOrderDTO) { + Utils.checkLimit(tokenProvider.getToken(request), 1, 400); return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO, false)); } @@ -202,6 +209,11 @@ public class TbPlaceController { return ResponseEntity.ok(tbShopTableService.pay(payDTO)); } + @PutMapping("/waitCall") + public ResponseEntity waitCall(@Valid @RequestBody WaitCallDTO waitCallDTO) { + return ResponseEntity.ok(tbShopTableService.waitCall(waitCallDTO)); + } + @PostMapping("/returnOrder") public ResponseEntity returnOrder(@RequestBody ReturnOrderDTO returnOrderDTO) { return ResponseEntity.ok(tbShopTableService.returnOrder(returnOrderDTO)); @@ -246,6 +258,14 @@ public class TbPlaceController { return ResponseEntity.ok(tbShopTableService.printDishes(baseTableDTO)); } + /** + * 美团核销 + */ + @PostMapping("checkCoupon") + public ResponseEntity checkCoupon(@Validated @RequestBody ThirdCouponCheckDTO checkDTO) { + return ResponseEntity.ok(tbShopTableService.checkCoupon(checkDTO)); + } + @AnonymousAccess @GetMapping("/test") public void test( diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/ShopInvoiceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/ShopInvoiceController.java new file mode 100644 index 00000000..e9de5b82 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/ShopInvoiceController.java @@ -0,0 +1,69 @@ +package cn.ysk.cashier.controller.shop; + +import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; +import cn.ysk.cashier.dto.BindingDto; +import cn.ysk.cashier.service.BindService; +import cn.ysk.cashier.service.shop.TbShopInfoService; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.Map; + +/** + * @author Administrator + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/invoice") +public class ShopInvoiceController { + + @Resource + private TbShopInfoService shopInfoService; + @Resource + private BindService bindService; + + @PostMapping("binding") + @ApiOperation("绑定开票信息") + public ResponseEntity binding(@Validated @RequestBody BindingDto bindingDto){ + return new ResponseEntity<>(shopInfoService.binding(bindingDto), HttpStatus.OK); + } + + @PostMapping("subInvoicing") + @ApiOperation("提交开票") + public ResponseEntity subInvoicing(@RequestBody Map params){ + return new ResponseEntity<>(bindService.subInvoicing(params), HttpStatus.OK); + } + + @PostMapping("industry") + @ApiOperation("获取项目分类") + @AnonymousPostMapping("industry") + public ResponseEntity industry(@RequestBody BindingDto bindingDto){ + return new ResponseEntity<>(bindService.industry(bindingDto), HttpStatus.OK); + } + + @PostMapping("digitalInvoice") + @ApiOperation("数电发票类型") + @AnonymousPostMapping("digitalInvoice") + public ResponseEntity digitalInvoice(){ + return new ResponseEntity<>(bindService.digitalInvoice(), HttpStatus.OK); + } + + @PostMapping("storeSe") + @ApiOperation("计算税额") + @AnonymousPostMapping("storeSe") + public ResponseEntity storeSe(@RequestBody Map params){ + return new ResponseEntity<>(bindService.storeSe(params), HttpStatus.OK); + } + + + + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java index cf037124..495c92f8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java @@ -1,17 +1,22 @@ package cn.ysk.cashier.controller.shop; import cn.ysk.cashier.annotation.Log; +import cn.ysk.cashier.annotation.rest.AnonymousGetMapping; import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; +import cn.ysk.cashier.config.security.config.bean.SecurityProperties; import cn.ysk.cashier.config.security.security.TokenProvider; import cn.ysk.cashier.config.security.service.OnlineUserService; +import cn.ysk.cashier.dto.BindingDto; import cn.ysk.cashier.dto.shop.TbShopInfoDto; import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; +import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.pojo.shop.TbShopInfo; import cn.ysk.cashier.service.shop.TbShopInfoService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; @@ -19,6 +24,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; import java.util.Map; /** @@ -36,14 +42,38 @@ public class TbShopInfoController { private final TbShopInfoService tbShopInfoService; private final OnlineUserService onlineUserService; private final TokenProvider tokenProvider; + private final SecurityProperties properties; -// @Log("导出数据") -// @ApiOperation("导出数据") -// @GetMapping(value = "/download") -// @PreAuthorize("@el.check('tbShopInfo:list')") -// public void exportTbShopInfo(HttpServletResponse response, TbShopInfoQueryCriteria criteria) throws IOException { -// tbShopInfoService.download(tbShopInfoService.queryAll(criteria), response); -// } + @PostMapping("changChildShop") + @ApiOperation("切换子店铺") + public ResponseEntity changChildShop(@RequestBody TbShopInfoQueryCriteria criteria, HttpServletRequest request) { + TbShopInfoDto shopInfo = tbShopInfoService.findById(criteria.getId()); + if (shopInfo != null) { + //生成token + String token = tokenProvider.createToken(shopInfo.getAccount(), criteria.getId().toString()); + Map authInfo = new HashMap(2) {{ + put("token", properties.getTokenStartWith() + token); + if (shopInfo != null) { + put("shopId", shopInfo.getId()); + put("mainId", StringUtils.isNotBlank(shopInfo.getMainId())?shopInfo.getId():shopInfo.getMainId()); + put("loginType", "merchant"); + put("shopName", shopInfo.getShopName()); + put("logo", shopInfo.getLogo()); + } + }}; + // 保存在线信息 + onlineUserService.save(shopInfo.getAccount(), shopInfo.getShopName(), token, request, shopInfo.getId()); + return ResponseEntity.ok(authInfo); + } else { + throw new BadRequestException("店铺信息不存在"); + } + } + + @GetMapping("queryChildShop") + @ApiOperation("查询子店铺") + public ResponseEntity queryChildShop(TbShopInfoQueryCriteria criteria){ + return new ResponseEntity<>(tbShopInfoService.queryChildShop(criteria),HttpStatus.OK); + } @GetMapping @ApiOperation("查询/shop/list") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BindingDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/BindingDto.java new file mode 100644 index 00000000..146293b9 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/BindingDto.java @@ -0,0 +1,20 @@ +package cn.ysk.cashier.dto; + +import lombok.Data; + +@Data +public class BindingDto { + private Integer shopId; + private String account; + + // 项目分类 + private String article; + + // 数电发票类型 + private String sdType; + + // 税率 + private String taxAmount; + + private Integer page = 1; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbShopSyncInfoQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbShopSyncInfoQueryCriteria.java new file mode 100644 index 00000000..feff2e2d --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbShopSyncInfoQueryCriteria.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.dto; + +import lombok.Data; + +/** + * 店铺信息同步记录表(TbShopSyncInfo)表查询类 + * + * @author ww + * @since 2024-11-25 16:46:12 + */ +@Data +public class TbShopSyncInfoQueryCriteria { + + //目的shop + private Integer pointShopId; + //1-正在 2-完成 + private Integer status; + + private long page = 1; + private long size = 10; +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/booking/ShopTableBookingDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/booking/ShopTableBookingDTO.java new file mode 100644 index 00000000..1d673f4f --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/booking/ShopTableBookingDTO.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.dto.booking; + +import cn.ysk.cashier.mybatis.entity.TbShopTableBooking; +import cn.ysk.cashier.pojo.shop.TbShopTable; +import lombok.Data; + +/** + * 店铺台桌及预订信息 + * + * @author tankaikai + * @since 2024-11-22 11:24 + */ +@Data +public class ShopTableBookingDTO extends TbShopTable { + private TbShopTableBooking bookingInfo; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/credit/CreditBuyerOrderDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/credit/CreditBuyerOrderDTO.java new file mode 100644 index 00000000..0ed9cf5b --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/credit/CreditBuyerOrderDTO.java @@ -0,0 +1,69 @@ +package cn.ysk.cashier.dto.credit; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 挂账账单 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Data +public class CreditBuyerOrderDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private Long id; + /** + * 订单id + */ + private Long orderId; + /** + * 挂账人编码 + */ + private String creditBuyerId; + /** + * 应付金额 + */ + private BigDecimal payAmount; + /** + * 已付金额 + */ + private BigDecimal paidAmount; + /** + * 未付金额 + */ + private BigDecimal unpaidAmount; + /** + * 状态 unpaid-未付款 partial-部分支付 paid-已付款 + */ + private String status; + /** + * 最近一次付款时间 + */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date lastPaymentTime; + /** + * 最近一次付款方式 + */ + private String lastPaymentMethod; + /** + * 备注 + */ + private String remark; + /** + * 创建时间 + */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoDto.java index 534f40af..1cd23a78 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoDto.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoDto.java @@ -37,6 +37,7 @@ public class TbShopInfoDto implements Serializable { /** 自增id */ private Integer id; + private String mainId; /** 店铺帐号 */ @NotBlank(message = "店铺账号不能为空") @@ -101,6 +102,8 @@ public class TbShopInfoDto implements Serializable { /** 未用 */ private String mchId; + private Integer tubeType; + private String registerType; /** 是否独立的微信小程序 */ @@ -112,7 +115,7 @@ public class TbShopInfoDto implements Serializable { /** 类似于这种规则51.51.570 */ private String city; - /** 店铺类型 超市--MARKET---其它店SHOP */ + /** 店铺类型 单店--only 连锁店--chain--加盟店join*/ private String type; /** 行业 */ diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java index 700b127c..e4b64d48 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java @@ -17,6 +17,7 @@ package cn.ysk.cashier.dto.shop; import lombok.Data; import cn.ysk.cashier.annotation.Query; +import org.apache.commons.lang3.StringUtils; /** * @website https://eladmin.vip @@ -35,9 +36,12 @@ public class TbShopInfoQueryCriteria{ private String account; /** 精确 */ - @Query(type = Query.Type.LEFT_LIKE) + @Query(type = Query.Type.INNER_LIKE) private String shopName; + @Query + private String type; + /** 精确 */ @Query private String phone; @@ -71,4 +75,16 @@ public class TbShopInfoQueryCriteria{ private Integer size; private String sort; + + public void setType(String type) { + if(StringUtils.isNotBlank(type)){ + this.type = type; + } + } + + public void setShopName(String shopName) { + if(StringUtils.isNotBlank(shopName)){ + this.shopName = shopName; + } + } } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopTableQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopTableQueryCriteria.java index 72099d7d..ef4b3645 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopTableQueryCriteria.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopTableQueryCriteria.java @@ -15,9 +15,8 @@ */ package cn.ysk.cashier.dto.shop; -import cn.ysk.cashier.enums.TableStateEnum; -import lombok.Data; import cn.ysk.cashier.annotation.Query; +import lombok.Data; import javax.validation.constraints.NotNull; @@ -43,8 +42,22 @@ public class TbShopTableQueryCriteria{ @Query private Long qrcode; + + /** + * 是否接受网络预订 + */ + @Query + private Integer isPredate; private String state; private Integer page = 1; private Integer size = 99999; + + public Integer getIsPredate() { + return isPredate; + } + + public void setIsPredate(Integer isPredate) { + this.isPredate = isPredate; + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java index 44335aaf..f8abd013 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java @@ -4,6 +4,7 @@ import lombok.Data; import javax.validation.constraints.*; import java.math.BigDecimal; +import java.util.List; @Data public class AddCartDTO { @@ -17,13 +18,16 @@ public class AddCartDTO { private Integer shopId; private String tableId; @NotNull - @DecimalMin("0.01") + @DecimalMin(value = "0.01", message = "数量最小为0.01") private BigDecimal num; private boolean isPack; private boolean isGift; private Integer cartId; private String note; + // 套餐商品选择的id信息 + private List groupProductIdList; + // 用餐类型 @NotBlank private String useType; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/CreateOrderDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/CreateOrderDTO.java index 558fd8b8..d755fe95 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/CreateOrderDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/CreateOrderDTO.java @@ -29,5 +29,6 @@ public class CreateOrderDTO { private List userCouponInfos = new ArrayList<>(); // 使用的积分抵扣数量 private Integer pointsNum; + private Integer isWaitCall; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java index b54bfc51..44f82220 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java @@ -22,6 +22,7 @@ public class PayDTO { private BigDecimal discount; private Integer vipUserId; private String code; + private Integer num; private String token; // 使用的优惠券 @Valid @@ -30,5 +31,6 @@ public class PayDTO { private Integer pointsNum; private Integer staffId; private String loginName; + private String creditBuyerId; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ThirdCouponCheckDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ThirdCouponCheckDTO.java new file mode 100644 index 00000000..d3b1a7d0 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ThirdCouponCheckDTO.java @@ -0,0 +1,25 @@ +package cn.ysk.cashier.dto.shoptable; + +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +@Data +public class ThirdCouponCheckDTO { + private String type = "meituan"; + @NotNull + private Integer shopId; + @NotBlank + private String code; + @Min(1) + private Integer num; + @NotNull + private Integer orderId; + // 核销的对应商品 + @NotEmpty + private List cartId; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java index 727fd87d..456c3092 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java @@ -7,14 +7,13 @@ import javax.validation.constraints.Min; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.math.BigDecimal; +import java.util.List; @Data public class UpdateCartDTO { @NotNull private Integer cartId; - @NotNull private Integer skuId; - @NotNull private Integer productId; @NotNull private Integer shopId; @@ -24,5 +23,12 @@ public class UpdateCartDTO { private String note; private Boolean isPack; private Boolean isGift; - private Boolean isPrint = true; + // 是否打印 + private Boolean isPrint; + // 是否等叫 + private Integer isWaitCall; + + // 套餐商品选择的id信息 + private List groupProductIdList; + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdatePriceDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdatePriceDTO.java new file mode 100644 index 00000000..78404fed --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdatePriceDTO.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.dto.shoptable; + +import lombok.Data; + +import javax.validation.constraints.DecimalMin; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; + +@Data +public class UpdatePriceDTO { + @NotNull + private Integer shopId; + @NotNull + private Integer cartId; + @DecimalMin(value = "0.01", message = "改价不能低于0.01元") + @NotNull + private BigDecimal saleAmount; + @NotBlank(message = "折扣原因不能为空") + private String note; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/WaitCallDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/WaitCallDTO.java new file mode 100644 index 00000000..d2e9de3c --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/WaitCallDTO.java @@ -0,0 +1,20 @@ +package cn.ysk.cashier.dto.shoptable; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +public class WaitCallDTO { + @NotNull + private Integer shopId; + @NotNull + private Integer isWaitCall; + private Integer orderId; + @NotBlank + private String masterId; + @NotBlank + private String useType; + private String tableId; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/BaseQueryDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/BaseQueryDTO.java new file mode 100644 index 00000000..96c474c9 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/BaseQueryDTO.java @@ -0,0 +1,11 @@ +package cn.ysk.cashier.dto.thirdcoupon; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class BaseQueryDTO { + @NotNull + private Integer shopId; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/CheckCouponDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/CheckCouponDTO.java new file mode 100644 index 00000000..53565f9f --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/CheckCouponDTO.java @@ -0,0 +1,18 @@ +package cn.ysk.cashier.dto.thirdcoupon; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@EqualsAndHashCode(callSuper = true) +@Data +public class CheckCouponDTO extends BaseQueryDTO { + @NotBlank + private String couponCode; + @NotNull + @Min(1) + private Integer num; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/GetActivateCouponDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/GetActivateCouponDTO.java new file mode 100644 index 00000000..656cb586 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/GetActivateCouponDTO.java @@ -0,0 +1,13 @@ +package cn.ysk.cashier.dto.thirdcoupon; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; + +@EqualsAndHashCode(callSuper = true) +@Data +public class GetActivateCouponDTO extends BaseQueryDTO{ + @NotBlank + private String code; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/RevokeCouponDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/RevokeCouponDTO.java new file mode 100644 index 00000000..34eb22c0 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/thirdcoupon/RevokeCouponDTO.java @@ -0,0 +1,13 @@ +package cn.ysk.cashier.dto.thirdcoupon; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; + +@EqualsAndHashCode(callSuper = true) +@Data +public class RevokeCouponDTO extends BaseQueryDTO{ + @NotBlank + private String couponCode; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java new file mode 100644 index 00000000..fa478af3 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyer.java @@ -0,0 +1,107 @@ +package cn.ysk.cashier.mybatis.entity; + +import cn.hutool.core.util.NumberUtil; +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; + +/** + * 挂账人 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("tb_credit_buyer") +public class TbCreditBuyer { + private static final long serialVersionUID = 1L; + + /** + * 挂账编码 + */ + @TableId(type = IdType.ASSIGN_ID) + private String id; + /** + * 店铺id + */ + private Integer shopId; + /** + * 状态 1-启用 0-停用 + */ + private Integer status; + /** + * 挂账人 + */ + private String debtor; + /** + * 手机号 + */ + private String mobile; + /** + * 职务 + */ + private String position; + /** + * 挂账额度 + */ + private BigDecimal creditAmount; + /** + * 账户余额 + */ + private BigDecimal accountBalance; + /** + * 还款方式 total-按总金额还款 order-按订单还款 + */ + private String repaymentMethod; + /** + * 支付方式 + */ + private String paymentMethod; + /** + * 责任人 + */ + private String responsiblePerson; + /** + * 备注 + */ + private String remark; + /** + * 删除标志 0-正常 1-删除 + */ + private Integer delFlag; + + + /** + * 已挂账金额 + */ + @TableField(value = "(select ifnull(sum(unpaid_amount),0) from view_credit_buyer_order where credit_buyer_id = tb_credit_buyer.id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + private BigDecimal owedAmount; + + /** + * 剩余挂账额度 + */ + @TableField(exist = false) + private BigDecimal remainingAmount; + + /** + * 累计挂账金额 + */ + @TableField(value = "(select ifnull(sum(pay_amount),0) from view_credit_buyer_order where credit_buyer_id = tb_credit_buyer.id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + private BigDecimal accumulateAmount; + + /** + * 适用门店 + */ + @TableField(value = "(select shop_name from tb_shop_info where id = tb_credit_buyer.shop_id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + private String shopName; + + /** + * 剩余挂账额度 + */ + public BigDecimal getRemainingAmount() { + return NumberUtil.sub(creditAmount, NumberUtil.null2Zero(owedAmount)); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyerOrder.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyerOrder.java new file mode 100644 index 00000000..93e6f038 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditBuyerOrder.java @@ -0,0 +1,60 @@ +package cn.ysk.cashier.mybatis.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 挂账账单 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("tb_credit_buyer_order") +public class TbCreditBuyerOrder { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 订单id + */ + private Long orderId; + /** + * 挂账人编码 + */ + private String creditBuyerId; + /** + * 已付金额 + */ + private BigDecimal paidAmount; + /** + * 状态 unpaid-未付款 partial-部分支付 paid-已付款 + */ + private String status; + /** + * 最近一次付款时间 + */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date lastPaymentTime; + /** + * 最近一次付款方式 + */ + private String lastPaymentMethod; + /** + * 备注 + */ + @TableField(value = "remark", updateStrategy = FieldStrategy.ALWAYS) + private String remark; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditPaymentRecord.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditPaymentRecord.java new file mode 100644 index 00000000..e6c6c097 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCreditPaymentRecord.java @@ -0,0 +1,63 @@ +package cn.ysk.cashier.mybatis.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 挂账账单付款记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_credit_payment_record") +public class TbCreditPaymentRecord { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 订单id + */ + private Long orderId; + /** + * 挂账人编码 + */ + private String creditBuyerId; + /** + * 还款金额 + */ + private BigDecimal repaymentAmount; + /** + * 支付方式 + */ + private String paymentMethod; + /** + * 备注 + */ + private String remark; + /** + * 还款时间 + */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date paymentTime; + /** + * 操作时间 + */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopSyncInfo.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopSyncInfo.java new file mode 100644 index 00000000..e25648ff --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopSyncInfo.java @@ -0,0 +1,56 @@ +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.extension.activerecord.Model; +import lombok.Data; + +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import java.io.Serializable; + +/** + * 店铺信息同步记录表(TbShopSyncInfo)表实体类 + * + * @author ww + * @since 2024-11-25 16:46:12 + */ +@Data +@SuppressWarnings("serial") +public class TbShopSyncInfo extends Model { + + @GeneratedValue(strategy = GenerationType.IDENTITY) + @TableId(type = IdType.AUTO) + private Integer id; + //源shop + private Integer sourceShopId; + //目的shop + private Integer pointShopId; + //分组同步数量 + private Integer proGroup; + //规格同步数量 + private Integer proSpec; + //单位同步数量 + private Integer proUnit; + //分类同步数量 + private Integer proCategory; + //商品同步数量 + private Integer product; + //规格同步数量 + private Integer proSku; + //商品同步数量 + private Integer proSkuResult; + //耗材类型同步数量 + private Integer consType; + //耗材信息同步数量 + private Integer consInfo; + //商品耗材关联同步数量 + private Integer consPro; + //1-正在 2-完成 + private Integer status; + //同步时间 + private Date syncTime; +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopTableBooking.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopTableBooking.java new file mode 100644 index 00000000..d5e8b9a6 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopTableBooking.java @@ -0,0 +1,129 @@ +package cn.ysk.cashier.mybatis.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 店铺台桌预订 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-21 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_shop_table_booking") +public class TbShopTableBooking { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 店铺桌台id + */ + private Integer shopTableId; + /** + * 店铺id + */ + private Integer shopId; + /** + * 订单编号 + */ + private String orderNo; + /** + * 预约日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @JSONField(format = "yyyy-MM-dd") + private Date bookingDate; + /** + * 预约类型 lunch-午餐 dinner-晚餐 + */ + private String bookingType; + /** + * 用餐人数 + */ + private Integer dinerNum; + /** + * 电话号码 + */ + private String phoneNumber; + /** + * 订餐人 + */ + private String bookingPerson; + /** + * 性别/称呼 1-先生 2-女士 + */ + private Integer gender; + /** + * 预约时间 + */ + private Date bookingTime; + /** + * 用餐类型 普通用餐/宴会套餐/自助餐/...,由前端定义或者输入文本 + */ + private String diningType; + /** + * 重点关注 1-是 0-否 + */ + private Integer focus; + /** + * 接收营销短信 1-是 0-否 + */ + private Integer receiveMarketingSms; + /** + * 摆台桌数 + */ + private Integer bookingTableNum; + /** + * 餐标(单价) + */ + private BigDecimal diningStandardPrice; + /** + * 餐标(单位) table-元/桌 person-元/人 + */ + private String diningStandardUnit; + /** + * 预订状态 -1-已取消 10-已到店 20-待到店 999-已超时 + * 注:此处定义为数字是为了方便按状态排序 + */ + private Integer status; + /** + * 留座时间 + */ + private Integer timeoutMinute; + /** + * 操作时间 + */ + private Date createTime; + /** + * 操作人 + */ + private String createUserName; + /** + * 到店时间 + */ + @TableField(value = "arrived_time", updateStrategy = FieldStrategy.ALWAYS) + private Date arrivedTime; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 备注 + */ + private String remark; + /** + * 删除标志 1-是 0-否 + */ + private Integer delFlag; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbThirdPartyCouponRecord.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbThirdPartyCouponRecord.java new file mode 100644 index 00000000..babe4b71 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbThirdPartyCouponRecord.java @@ -0,0 +1,47 @@ +package cn.ysk.cashier.mybatis.entity; + +import lombok.Getter; +import lombok.Setter; + +import javax.persistence.*; +import javax.validation.constraints.Size; +import java.time.Instant; +import java.util.List; + +@Getter +@Setter +@Entity +@Table(name = "tb_third_party_coupon_record") +public class TbThirdPartyCouponRecord { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Integer id; + + @Column(name = "order_id") + private Integer orderId; + + @Column(name = "state") + private Byte state; + + @Size(max = 255) + @Column(name = "plat") + private String plat; + + @Size(max = 50) + @Column(name = "code", length = 50) + private String code; + + private Integer num; + + @Column(name = "create_time") + private Instant createTime; + + @Column(name = "check_time") + private Instant checkTime; + + @Column(name = "shop_id") + private Integer shopId; + private String cartIdList; + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerMapper.java new file mode 100644 index 00000000..e4a8efc4 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbCreditBuyer; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* 挂账人 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-11-20 +*/ +@Mapper +public interface TbCreditBuyerMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java new file mode 100644 index 00000000..a608b1f7 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditBuyerOrderMapper.java @@ -0,0 +1,33 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.dto.credit.CreditBuyerOrderDTO; +import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** + * 挂账账单 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Mapper +public interface TbCreditBuyerOrderMapper extends BaseMapper { + + List getList(Map params); + + long getCount(Map params); + + BigDecimal getSumPayAmount(Map params); + + BigDecimal getSumPaidAmount(Map params); + + BigDecimal getSumUnpaidAmount(Map params); + + CreditBuyerOrderDTO getOne(Map params); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditPaymentRecordMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditPaymentRecordMapper.java new file mode 100644 index 00000000..ad01d1d3 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCreditPaymentRecordMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* 挂账账单付款记录 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-11-20 +*/ +@Mapper +public interface TbCreditPaymentRecordMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopSyncInfoMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopSyncInfoMapper.java new file mode 100644 index 00000000..5f535b7e --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopSyncInfoMapper.java @@ -0,0 +1,17 @@ +package cn.ysk.cashier.mybatis.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import cn.ysk.cashier.mybatis.entity.TbShopSyncInfo; +import org.apache.ibatis.annotations.Mapper; + +/** + * 店铺信息同步记录表(TbShopSyncInfo)表数据库访问层 + * + * @author ww + * @since 2024-11-25 16:46:12 + */ +@Mapper +public interface TbShopSyncInfoMapper extends BaseMapper { + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopTableBookingMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopTableBookingMapper.java new file mode 100644 index 00000000..7e98808d --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopTableBookingMapper.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbShopTableBooking; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * 店铺台桌预订 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-21 + */ +@Mapper +public interface TbShopTableBookingMapper extends BaseMapper { + + List> summaryByPhoneNos(@Param("shopId") Integer shopId, @Param("phoneNoList") List phoneNoList); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbThirdPartyCouponRecordMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbThirdPartyCouponRecordMapper.java new file mode 100644 index 00000000..3ca58f49 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbThirdPartyCouponRecordMapper.java @@ -0,0 +1,18 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author Administrator +* @description 针对表【tb_third_party_coupon_record】的数据库操作Mapper +* @createDate 2024-11-25 17:57:03 +* @Entity cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord +*/ +public interface TbThirdPartyCouponRecordMapper extends BaseMapper { + +} + + + + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java index 0121bd73..1c0d33fa 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java @@ -4,8 +4,10 @@ import cn.ysk.cashier.cons.TableConstant; import cn.ysk.cashier.dto.shoptable.ShopEatTypeInfoDTO; import cn.ysk.cashier.enums.OrderStatusEnums; import cn.ysk.cashier.pojo.order.TbCashierCart; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.ArrayList; import java.util.List; /** @@ -60,9 +62,14 @@ public interface MpCashierCartService extends IService { /** * 根据店就餐模式查询购物车 * @param shopEatTypeInfoDTO 就餐模式 + * @param masterId 取餐码 + * @param statuses 状态 为空默认查询 create return * @return 购物车信息 */ - List selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId); + List selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, TableConstant.OrderInfo.Status... statuses); + + + List selectByShopEatTypeAndOrderId(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer orderId, TableConstant.OrderInfo.Status... statuses); /** * 根据订单id和状态获取购物车数据 @@ -73,5 +80,31 @@ public interface MpCashierCartService extends IService { boolean updateMemberAndAmountByOrderId(Integer orderId, boolean isMember); + + /** + * 根据就餐信息查询购物车信息 + * @param shopEatTypeInfoDTO 就餐信息 + * @return 购物车信息 + */ + TbCashierCart selectOneCartByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer productId, Integer skuId, boolean isGift, boolean isTemp); + + /** + * 根据店铺id和购物车id查询信息 + * @param shopId 店铺id + * @param cartId 购物车id + * @param statuses 状态 + */ + TbCashierCart selectByShopIdAndId(Integer shopId, Integer cartId, TableConstant.OrderInfo.Status... statuses); + + /** + * 根据id查询购物车数据 + * @param shopId 店铺id + * @param orderId 订单id + * @param ids 购物车id + * @param statuses 状态 + */ + List selectByIds(Integer shopId, Integer orderId, List ids, TableConstant.OrderInfo.Status... statuses); + + boolean updateFieldValByIds(Integer shopId, ArrayList cartIds, SFunction column, Object val); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java index c1d059a3..bdf3c773 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java @@ -5,11 +5,13 @@ import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO; import cn.ysk.cashier.enums.OrderStatusEnums; import cn.ysk.cashier.pojo.order.TbFullOrderDetail; import cn.ysk.cashier.pojo.order.TbOrderDetail; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.service.IService; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; +import java.util.function.Supplier; /** * (TbShopPermission)表服务接口 @@ -78,5 +80,7 @@ public interface MpOrderDetailService extends IService { * @param isMember 会员id */ boolean updateMemberByOrderId(Integer orderId, boolean isMember); + + boolean updateFieldByCartId(SFunction field, Object val, List cartIds); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java index fe49c351..5630aa6a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java @@ -4,8 +4,10 @@ import cn.ysk.cashier.cons.TableConstant; import cn.ysk.cashier.enums.OrderStatusEnums; import cn.ysk.cashier.pojo.order.TbOrderDetail; import cn.ysk.cashier.pojo.order.TbOrderInfo; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.service.IService; +import java.math.BigDecimal; import java.util.List; /** @@ -40,5 +42,11 @@ public interface MpOrderInfoService extends IService { */ TbOrderInfo selectOrderByIdAndState(Integer orderId, TableConstant.OrderInfo.Status status); + boolean incrAmount(Integer orderId, BigDecimal subtract); + + + boolean updateFieldVal(Integer shopId, Integer orderId, SFunction column, Object val); + + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java new file mode 100644 index 00000000..01b0c8ab --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerOrderService.java @@ -0,0 +1,37 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder; +import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.Map; + +/** + * 挂账账单 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +public interface TbCreditBuyerOrderService extends IService { + + Map page(Map params); + Map summary(Map params); + + void pay(TbCreditPaymentRecord record); + + /** + * 保存挂账账单 + * @param creditBuyerId 挂账人id + * @param orderId 订单id + */ + boolean save(String creditBuyerId, Long orderId); + + /** + * 挂账人退款 + * @param creditBuyerId 挂账人id + * @param orderId 订单id + * @return + */ + boolean refund(String creditBuyerId, Long orderId); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerService.java new file mode 100644 index 00000000..32240ac1 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditBuyerService.java @@ -0,0 +1,29 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.mybatis.entity.TbCreditBuyer; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.Map; + +/** + * 挂账人 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +public interface TbCreditBuyerService extends IService { + + Map page(Map params); + + boolean save(TbCreditBuyer entity); + + boolean update(TbCreditBuyer dto); + + void delete(String id); + + TbCreditBuyer getById(String id); + + Map repayment(Map params); + + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditPaymentRecordService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditPaymentRecordService.java new file mode 100644 index 00000000..fd9b5946 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCreditPaymentRecordService.java @@ -0,0 +1,18 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.Map; + +/** + * 挂账账单付款记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +public interface TbCreditPaymentRecordService extends IService { + + Map page(Map params); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopSyncInfoService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopSyncInfoService.java new file mode 100644 index 00000000..a6573378 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopSyncInfoService.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.mybatis.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import cn.ysk.cashier.mybatis.entity.TbShopSyncInfo; +import cn.ysk.cashier.dto.TbShopSyncInfoQueryCriteria; + +import java.util.Map; + +/** + * 店铺信息同步记录表(TbShopSyncInfo)表服务接口 + * + * @author ww + * @since 2024-11-25 16:46:12 + */ +public interface TbShopSyncInfoService extends IService { + + TbShopSyncInfo queryByShopId(TbShopSyncInfoQueryCriteria criteria); + void sync(TbShopSyncInfo tbShopSyncInfo); + void clear(TbShopSyncInfo tbShopSyncInfo); + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java new file mode 100644 index 00000000..28d95c8d --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopTableBookingService.java @@ -0,0 +1,44 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.dto.booking.ShopTableBookingDTO; +import cn.ysk.cashier.mybatis.entity.TbShopTableBooking; +import cn.ysk.cashier.pojo.shop.TbShopArea; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; +import java.util.Map; + +/** + * 店铺台桌预订 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-21 + */ +public interface TbShopTableBookingService extends IService { + + Map page(Map params); + + String booking(TbShopTableBooking entity); + + boolean update(TbShopTableBooking dto); + + void markStatus(Long id, Integer status); + + void delete(Long id); + + /** + * 获取待发送的短信内容 + * @param shopId 店铺id + */ + String getBookingSms(Integer shopId); + + List findShopAreaList(Integer shopId); + + List findShopTableList(Map params); + + Map summary(Integer shopId,String[] phoneNos); + + void batchTimeout(); + + void autoCancel(); +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbThirdPartyCouponRecordService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbThirdPartyCouponRecordService.java new file mode 100644 index 00000000..5277b6d2 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbThirdPartyCouponRecordService.java @@ -0,0 +1,13 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author Administrator +* @description 针对表【tb_third_party_coupon_record】的数据库操作Service +* @createDate 2024-11-25 17:57:03 +*/ +public interface TbThirdPartyCouponRecordService extends IService { + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java index 94ca64a6..7bc07258 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java @@ -1,6 +1,7 @@ package cn.ysk.cashier.mybatis.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.cons.TableConstant; @@ -16,6 +17,7 @@ import cn.ysk.cashier.pojo.shop.TbShopInfo; import cn.ysk.cashier.pojo.shop.TbShopTable; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; @@ -108,14 +110,53 @@ public class MpCashierCartServiceImpl extends ServiceImpl selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId) { + public List selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, TableConstant.OrderInfo.Status... statuses) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() .eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopId()) .eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()) - .in(TbCashierCart::getStatus, "create", "return") .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) .and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId)); + if (statuses.length == 0) { + queryWrapper.in(TbCashierCart::getStatus, "create", "return"); + } else { + queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses)); + } + + // 非堂食校验台桌状态 + if (shopEatTypeInfoDTO.isTakeout()) { + queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "")) + .in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue()); + } else { + if (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) { + queryWrapper.eq(TbCashierCart::getTableId, shopEatTypeInfoDTO.getTableId()); + } else { + queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "")); + } + + } + return list(queryWrapper); + } + + @Override + public List selectByShopEatTypeAndOrderId(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer orderId, TableConstant.OrderInfo.Status... statuses) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopId()) + .eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()) + .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) + .and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId)); + + if (statuses.length == 0) { + queryWrapper.in(TbCashierCart::getStatus, "create", "return"); + } else { + queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses)); + } + + if (orderId != null) { + queryWrapper.and(q -> q.eq(TbCashierCart::getOrderId, orderId) + .or().isNull(TbCashierCart::getOrderId)); + } + // 非堂食校验台桌状态 if (shopEatTypeInfoDTO.isTakeout()) { queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "")) @@ -139,5 +180,64 @@ public class MpCashierCartServiceImpl extends ServiceImpl query = new LambdaQueryWrapper() + .eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopId()) + .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) + .isNull(TbCashierCart::getPlaceNum) + .eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()) + .eq(TbCashierCart::getStatus, "create") + .eq(TbCashierCart::getIsGift, isGift) + .and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId)); + if (isTemp) { + query.isNull(TbCashierCart::getProductId).isNull(TbCashierCart::getSkuId).eq(TbCashierCart::getIsTemporary, 1); + } else { + query.eq(TbCashierCart::getProductId, productId) + .eq(TbCashierCart::getSkuId, skuId); + } + + // 外带只查询pc和收银机商品 + if (shopEatTypeInfoDTO.isTakeout()) { + query.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "")) + .in(TbCashierCart::getPlatformType, "pc", "cash"); + } else { + query.eq(TbCashierCart::getTableId, shopEatTypeInfoDTO.getTableId()); + } + + return getOne(query); + } + + @Override + public TbCashierCart selectByShopIdAndId(Integer shopId, Integer cartId, TableConstant.OrderInfo.Status... statuses) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(TbCashierCart::getShopId, shopId) + .eq(TbCashierCart::getId, cartId); + if (statuses.length != 0) { + queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses)); + } + return getOne(queryWrapper); + } + + @Override + public List selectByIds(Integer shopId, Integer orderId, List ids, TableConstant.OrderInfo.Status... statuses) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(TbCashierCart::getShopId, shopId) + .eq(TbCashierCart::getOrderId, orderId) + .in(TbCashierCart::getId, ids); + if (statuses.length != 0) { + queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses)); + } + return list(queryWrapper); + } + + @Override + public boolean updateFieldValByIds(Integer shopId, ArrayList cartIds, SFunction column, Object val) { + return update(new LambdaUpdateWrapper() + .eq(TbCashierCart::getShopId, shopId) + .in(TbCashierCart::getId, cartIds) + .set(column, val)); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java index ceef2831..318090ba 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java @@ -2,19 +2,18 @@ package cn.ysk.cashier.mybatis.service.impl; import cn.hutool.core.collection.CollUtil; import cn.ysk.cashier.cons.TableConstant; -import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO; import cn.ysk.cashier.enums.OrderStatusEnums; import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper; import cn.ysk.cashier.mybatis.service.MpOrderDetailService; import cn.ysk.cashier.pojo.order.TbOrderDetail; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Collections; import java.util.List; /** @@ -88,5 +87,15 @@ public class MpOrderDetailServiceImpl extends ServiceImpl field, Object val, List cartIds) { + LambdaUpdateWrapper query = new LambdaUpdateWrapper() + .set(field, val); + if (!cartIds.isEmpty()) { + query.in(TbOrderDetail::getCartId, cartIds); + } + return update(query); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java index 230128b8..c66b5717 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java @@ -1,5 +1,6 @@ package cn.ysk.cashier.mybatis.service.impl; +import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.cons.TableConstant; import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper; import cn.ysk.cashier.mybatis.mapper.TbOrderInfoMapper; @@ -9,9 +10,12 @@ import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.pojo.order.TbOrderInfo; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import java.math.BigDecimal; + /** * (TbShopPermission)表服务实现类 * @@ -40,5 +44,26 @@ public class MpOrderInfoServiceImpl extends ServiceImpl() + .eq(TbOrderInfo::getId, orderId) + .eq(TbOrderInfo::getStatus, TableConstant.OrderInfo.Status.UNPAID.getValue()) + .apply(StrUtil.format("settlement_amount + {} >= 0", subtract)) + .setSql(StrUtil.format("settlement_amount=settlement_amount+{}", subtract)) + .setSql(StrUtil.format("order_amount=order_amount+{}", subtract)) + .setSql(StrUtil.format("amount=amount+{}", subtract)) + .setSql(StrUtil.format("origin_amount=origin_amount+{}", subtract)) + ); + } + + @Override + public boolean updateFieldVal(Integer shopId, Integer orderId, SFunction column, Object val) { + return update(new LambdaUpdateWrapper() + .eq(TbOrderInfo::getShopId, shopId) + .eq(TbOrderInfo::getId, orderId) + .set(column, val)); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java new file mode 100644 index 00000000..2f6fa687 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerOrderServiceImpl.java @@ -0,0 +1,292 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.dto.credit.CreditBuyerOrderDTO; +import cn.ysk.cashier.dto.product.PadProductCategoryDTO; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.entity.TbCreditBuyer; +import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder; +import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; +import cn.ysk.cashier.mybatis.mapper.TbCreditBuyerMapper; +import cn.ysk.cashier.mybatis.mapper.TbCreditBuyerOrderMapper; +import cn.ysk.cashier.mybatis.mapper.TbCreditPaymentRecordMapper; +import cn.ysk.cashier.mybatis.service.MpOrderInfoService; +import cn.ysk.cashier.mybatis.service.TbCreditBuyerOrderService; +import cn.ysk.cashier.mybatis.service.TbCreditBuyerService; +import cn.ysk.cashier.pojo.order.TbOrderInfo; +import cn.ysk.cashier.utils.PageUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.*; + +/** + * 挂账账单 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Service +public class TbCreditBuyerOrderServiceImpl extends ServiceImpl implements TbCreditBuyerOrderService { + + @Resource + private TbCreditBuyerService tbCreditBuyerService; + @Resource + private TbCreditBuyerMapper tbCreditBuyerMapper; + @Resource + private TbCreditPaymentRecordMapper tbCreditPaymentRecordMapper; + @Resource + private MpOrderInfoService mpOrderInfoService; + + private LambdaQueryWrapper getWrapper(Map params) { + MapProxy mapProxy = MapProxy.create(params); + String beginDate = mapProxy.getStr("beginDate"); + String endDate = mapProxy.getStr("endDate"); + TbCreditBuyerOrder param = BeanUtil.toBean(params, TbCreditBuyerOrder.class); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.orderByDesc(TbCreditBuyerOrder::getOrderId); + return wrapper; + } + + @Override + public Map page(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + Page page = new Page<>(pageNum, pageSize); + page.addOrder(OrderItem.desc("order_id")); + params.put("page", page); + List list = baseMapper.getList(params); + return PageUtil.toPlusPage(list, Convert.toInt(page.getTotal())); + } + + @Override + public Map summary(Map params) { + long count = baseMapper.getCount(params); + Map data = new HashMap<>(5); + // 总交易笔数 + data.put("count", count); + // 总交易金额 + BigDecimal payAmount = baseMapper.getSumPayAmount(params); + data.put("payAmountTotal", payAmount); + + // 待支付笔数 + params.put("statusList", Arrays.asList("unpaid", "partial")); + long unpaidCount = baseMapper.getCount(params); + data.put("unpaidCount", unpaidCount); + params.put("statusList", Arrays.asList("paid", "partial")); + BigDecimal paidAmount = baseMapper.getSumPaidAmount(params); + params.put("statusList", Arrays.asList("unpaid", "partial")); + BigDecimal unpaidAmount = baseMapper.getSumUnpaidAmount(params); + data.put("paidAmountTotal", paidAmount); + data.put("unpaidAmountTotal", unpaidAmount); + return data; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void pay(TbCreditPaymentRecord record) { + try { + Assert.notNull(record.getCreditBuyerId(), "{}({})不能为空", "挂账人id", "creditBuyerId"); + Assert.notNull(record.getOrderId(), "{}({})不能为空", "订单id", "orderId"); + Assert.notNull(record.getRepaymentAmount(), "{}({})不能为空", "还款金额", "repaymentAmount"); + Assert.notEmpty(record.getPaymentMethod(), "{}({})不能为空", "支付方式", "paymentMethod"); + //Assert.notNull(record.getPaymentTime(), "{}({})不能为空", "还款时间", "paymentTime"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + TbCreditBuyer creditBuyer = tbCreditBuyerMapper.selectById(record.getCreditBuyerId()); + if (creditBuyer == null) { + throw new BadRequestException("挂账人不存在"); + } + String repaymentMethod = creditBuyer.getRepaymentMethod(); + if (!"order".equals(repaymentMethod)) { + throw new BadRequestException("该挂账人不支持按订单付款"); + } + Map params = new HashMap<>(2); + params.put("creditBuyerId", record.getCreditBuyerId()); + params.put("orderId", record.getOrderId()); + CreditBuyerOrderDTO dto = baseMapper.getOne(params); + if (dto == null) { + throw new BadRequestException("挂账订单不存在"); + } + if ("paid".equals(dto.getStatus())) { + throw new BadRequestException("挂账订单已还清,无需还款"); + } + if (NumberUtil.isLess(record.getRepaymentAmount(), BigDecimal.ZERO)) { + throw new BadRequestException("还款金额不能小于0"); + } + if (NumberUtil.isGreater(record.getRepaymentAmount(), dto.getUnpaidAmount())) { + throw new BadRequestException("还款金额不能大于未支付金额"); + } + TbCreditBuyerOrder entity = BeanUtil.copyProperties(dto, TbCreditBuyerOrder.class); + if (NumberUtil.equals(record.getRepaymentAmount(), dto.getUnpaidAmount())) { + entity.setStatus("paid"); + } else { + entity.setStatus("partial"); + } + entity.setPaidAmount(NumberUtil.add(entity.getPaidAmount(), record.getRepaymentAmount())); + entity.setLastPaymentTime(new Date()); + entity.setLastPaymentMethod(record.getPaymentMethod()); + entity.setRemark(record.getRemark()); + super.updateById(entity); + record.setCreateTime(new Date()); + record.setPaymentTime(new Date()); + tbCreditPaymentRecordMapper.insert(record); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean save(String creditBuyerId, Long orderId) { + if (StrUtil.isBlank(creditBuyerId)) { + throw new BadRequestException("挂账人id不能为空"); + } + TbCreditBuyer creditBuyer = tbCreditBuyerService.getById(creditBuyerId); + if (creditBuyer == null) { + throw new BadRequestException("挂账人不存在"); + } + Integer delFlag = creditBuyer.getDelFlag(); + if (delFlag != null && delFlag == 1) { + throw new BadRequestException("挂账人已删除"); + } + Integer status = creditBuyer.getStatus(); + if (status != null && status == 0) { + throw new BadRequestException("挂账人已被停用"); + } + TbOrderInfo orderInfo = mpOrderInfoService.getById(orderId); + if (orderInfo == null) { + throw new BadRequestException("订单不存在"); + } + // 账户余额 + BigDecimal accountBalance = creditBuyer.getAccountBalance(); + // 如果有余额的话,从余额里面扣除,没有余额的话,从信用额度里面扣除,余额和信用额度都为0,则不允许挂账,余额+信用额度刚好够支付这笔订单的话需要同时减余额减信用额度 + if (NumberUtil.isGreaterOrEqual(accountBalance, orderInfo.getOrderAmount())) { + // 减余额 + creditBuyer.setAccountBalance(NumberUtil.sub(accountBalance, orderInfo.getOrderAmount())); + tbCreditBuyerMapper.updateById(creditBuyer); + // 记录还款记录 + TbCreditPaymentRecord record = new TbCreditPaymentRecord(); + record.setCreditBuyerId(creditBuyerId); + record.setOrderId(orderId); + record.setRepaymentAmount(orderInfo.getOrderAmount()); + record.setPaymentMethod("余额支付"); + record.setPaymentTime(new Date()); + record.setRemark("挂账时余额充足,直接从余额扣除"); + record.setCreateTime(new Date()); + tbCreditPaymentRecordMapper.insert(record); + TbCreditBuyerOrder entity = new TbCreditBuyerOrder(); + entity.setCreditBuyerId(creditBuyerId); + entity.setOrderId(orderId); + entity.setPaidAmount(orderInfo.getOrderAmount()); + entity.setStatus("paid"); + entity.setLastPaymentTime(new Date()); + entity.setLastPaymentMethod(record.getPaymentMethod()); + entity.setRemark(record.getRemark()); + return super.save(entity); + } + TbCreditBuyerOrder entity = null; + if (NumberUtil.isGreater(accountBalance, BigDecimal.ZERO)) { + // 减余额 + creditBuyer.setAccountBalance(BigDecimal.ZERO); + tbCreditBuyerMapper.updateById(creditBuyer); + // 记录还款记录 + TbCreditPaymentRecord record = new TbCreditPaymentRecord(); + record.setCreditBuyerId(creditBuyerId); + record.setOrderId(orderId); + record.setRepaymentAmount(accountBalance); + record.setPaymentMethod("余额支付"); + record.setPaymentTime(new Date()); + record.setRemark("挂账时余额不足,先扣除现有余额,其他的从挂账额度中扣除"); + record.setCreateTime(new Date()); + tbCreditPaymentRecordMapper.insert(record); + entity = new TbCreditBuyerOrder(); + entity.setCreditBuyerId(creditBuyerId); + entity.setOrderId(orderId); + entity.setPaidAmount(accountBalance); + entity.setStatus("partial"); + entity.setLastPaymentTime(new Date()); + entity.setLastPaymentMethod(record.getPaymentMethod()); + entity.setRemark(record.getRemark()); + //super.save(entity); + orderInfo.setPayAmount(NumberUtil.sub(orderInfo.getOrderAmount(), accountBalance)); + } + // 剩余挂账额度 + BigDecimal remainingAmount = creditBuyer.getRemainingAmount(); + // 验证挂账金额是否大于剩余额度 + boolean greater = NumberUtil.isGreater(orderInfo.getOrderAmount(), remainingAmount); + if (greater) { + throw new BadRequestException(StrUtil.format("{}:¥{}不能大于剩余挂账额度({})", "挂账金额", orderInfo.getOrderAmount(), remainingAmount)); + } + if (entity == null) { + entity = new TbCreditBuyerOrder(); + entity.setStatus("unpaid"); + entity.setPaidAmount(BigDecimal.ZERO); + entity.setCreditBuyerId(creditBuyerId); + entity.setOrderId(orderId); + } + return super.saveOrUpdate(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean refund(String creditBuyerId, Long orderId) { + if (StrUtil.isBlank(creditBuyerId)) { + throw new BadRequestException("挂账人id不能为空"); + } + TbCreditBuyer creditBuyer = tbCreditBuyerService.getById(creditBuyerId); + if (creditBuyer == null) { + throw new BadRequestException("挂账人不存在"); + } + TbOrderInfo orderInfo = mpOrderInfoService.getById(orderId); + if (orderInfo == null) { + throw new BadRequestException("订单不存在"); + } + + Map params = new HashMap<>(2); + params.put("creditBuyerId", creditBuyerId); + params.put("orderId", orderId); + CreditBuyerOrderDTO dto = baseMapper.getOne(params); + if (dto == null) { + throw new BadRequestException("挂账订单不存在"); + } + // 1.只挂账未还款的情况,直接删除挂账订单 + if ("unpaid".equals(dto.getStatus())) { + baseMapper.deleteById(dto.getId()); + return true; + } + // 2.部分还款/已还款,删除挂账订单+红冲还款记录,并把已还款金额退回余额或挂账额度 + if ("partial".equals(dto.getStatus()) || "paid".equals(dto.getStatus())) { + // 已还款金额 + BigDecimal paidAmount = dto.getPaidAmount(); + // 已还款金额进行红冲 + TbCreditPaymentRecord record = new TbCreditPaymentRecord(); + record.setCreditBuyerId(creditBuyerId); + record.setOrderId(orderId); + record.setRepaymentAmount(NumberUtil.sub(BigDecimal.ZERO, paidAmount)); + record.setPaymentMethod("挂账退款"); + record.setPaymentTime(new Date()); + record.setRemark(StrUtil.format("挂账订单:{}申请退款,已归还挂账额度或账户余额", orderInfo.getOrderNo())); + record.setCreateTime(new Date()); + tbCreditPaymentRecordMapper.insert(record); + // 删除挂账订单,恢复挂账额度 + baseMapper.deleteById(dto.getId()); + // 退回余额 + creditBuyer.setAccountBalance(NumberUtil.add(creditBuyer.getAccountBalance(), paidAmount)); + tbCreditBuyerService.updateById(creditBuyer); + return true; + } + return false; + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java new file mode 100644 index 00000000..d051bfbf --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditBuyerServiceImpl.java @@ -0,0 +1,304 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.lang.Validator; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.dto.credit.CreditBuyerOrderDTO; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.entity.TbCreditBuyer; +import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder; +import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; +import cn.ysk.cashier.mybatis.mapper.TbCreditBuyerMapper; +import cn.ysk.cashier.mybatis.mapper.TbCreditBuyerOrderMapper; +import cn.ysk.cashier.mybatis.mapper.TbCreditPaymentRecordMapper; +import cn.ysk.cashier.mybatis.service.TbCreditBuyerService; +import cn.ysk.cashier.utils.PageUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 挂账人 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Service +public class TbCreditBuyerServiceImpl extends ServiceImpl implements TbCreditBuyerService { + + @Resource + private TbCreditBuyerOrderMapper tbCreditBuyerOrderMapper; + + @Resource + private TbCreditPaymentRecordMapper tbCreditPaymentRecordMapper; + + private LambdaQueryWrapper getWrapper(Map params) { + MapProxy mapProxy = MapProxy.create(params); + String keywords = mapProxy.getStr("keywords"); + String repaymentStatus = mapProxy.getStr("repaymentStatus"); + TbCreditBuyer param = BeanUtil.toBean(params, TbCreditBuyer.class); + + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbCreditBuyer::getShopId, param.getShopId()); + wrapper.eq(StrUtil.isNotEmpty(param.getId()), TbCreditBuyer::getId, param.getId()); + wrapper.like(StrUtil.isNotEmpty(param.getResponsiblePerson()), TbCreditBuyer::getResponsiblePerson, param.getResponsiblePerson()); + wrapper.eq(param.getStatus() != null, TbCreditBuyer::getStatus, param.getStatus()); + if (StrUtil.isNotEmpty(keywords)) { + wrapper.nested(i -> i.like(TbCreditBuyer::getDebtor, keywords).or().like(TbCreditBuyer::getMobile, keywords)); + } + if (StrUtil.isNotEmpty(repaymentStatus)) { + if ("unpaid".equals(repaymentStatus)) { + wrapper.apply("0 < ifnull((select x.count from view_credit_buyer_order_count x where x.credit_buyer_id = tb_credit_buyer.id and x.status = 'unpaid'),0)"); + wrapper.apply("0 = ifnull((select x.count from view_credit_buyer_order_count x where x.credit_buyer_id = tb_credit_buyer.id and x.status = 'partial'),0)"); + } else if ("partial".equals(repaymentStatus)) { + wrapper.apply("0 < ifnull((select x.count from view_credit_buyer_order_count x where x.credit_buyer_id = tb_credit_buyer.id and x.status = 'partial'),0)"); + } else if ("paid".equals(repaymentStatus)) { + wrapper.apply("0 = ifnull((select sum(x.count) from view_credit_buyer_order_count x where x.credit_buyer_id = tb_credit_buyer.id and x.status in ('unpaid','partial')),0)"); + } + } + wrapper.eq(TbCreditBuyer::getDelFlag, 0); + wrapper.select(TbCreditBuyer::getId, TbCreditBuyer::getShopId, TbCreditBuyer::getStatus, TbCreditBuyer::getDebtor, TbCreditBuyer::getMobile, TbCreditBuyer::getPosition, TbCreditBuyer::getCreditAmount, TbCreditBuyer::getRepaymentMethod, TbCreditBuyer::getPaymentMethod, TbCreditBuyer::getRemark, TbCreditBuyer::getDelFlag, TbCreditBuyer::getOwedAmount, TbCreditBuyer::getAccumulateAmount, TbCreditBuyer::getShopName, TbCreditBuyer::getResponsiblePerson, TbCreditBuyer::getAccountBalance); + wrapper.orderByDesc(TbCreditBuyer::getStatus); + wrapper.orderByDesc(TbCreditBuyer::getId); + return wrapper; + } + + @Override + public Map page(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + LambdaQueryWrapper wrapper = getWrapper(params); + Page page = super.page(new Page<>(pageNum, pageSize), wrapper); + return PageUtil.toPlusPage(page.getRecords(), Convert.toInt(page.getTotal())); + } + + private void commonVerify(TbCreditBuyer entity) { + try { + Assert.notNull(entity.getShopId(), "{}({})不能为空", "店铺id", "shopId"); + Assert.notNull(entity.getStatus(), "{}({})不能为空", "状态", "status"); + Assert.notEmpty(entity.getDebtor(), "{}({})不能为空", "挂账人", "debtor"); + Assert.notEmpty(entity.getMobile(), "{}({})不能为空", "手机号", "mobile"); + Assert.notNull(entity.getCreditAmount(), "{}({})不能为空", "挂账额度", "creditAmount"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + if (!Validator.isMobile(entity.getMobile())) { + throw new BadRequestException(StrUtil.format("{}({})不合法", "手机号", "mobile")); + } + if (NumberUtil.isLessOrEqual(entity.getCreditAmount(), BigDecimal.ZERO)) { + throw new BadRequestException(StrUtil.format("{}({})必须大于0", "挂账额度", "creditAmount")); + } + } + + @Override + public boolean save(TbCreditBuyer entity) { + commonVerify(entity); + try { + Assert.notEmpty(entity.getRepaymentMethod(), "{}({})不能为空", "还款方式", "repaymentMethod"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + if (!ArrayUtil.contains(new String[]{"total", "order"}, entity.getRepaymentMethod())) { + throw new BadRequestException(StrUtil.format("{}({})不合法", "还款方式", "repaymentMethod")); + } + entity.setAccountBalance(BigDecimal.ZERO); + return super.save(entity); + } + + @Override + public boolean update(TbCreditBuyer dto) { + try { + Assert.notEmpty(dto.getId(), "{}不能为空", "id"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + commonVerify(dto); + TbCreditBuyer entity = super.getById(dto.getId()); + if (entity == null) { + throw new BadRequestException("挂账人不存在"); + } + Map params = new HashMap<>(); + params.put("id", dto.getId()); + params.put("shopId", dto.getShopId()); + LambdaQueryWrapper wrapper = getWrapper(params); + entity = baseMapper.selectOne(wrapper); + + // 验证挂账额度是否小于已挂账金额 + boolean less = NumberUtil.isLess(dto.getCreditAmount(), NumberUtil.null2Zero(entity.getOwedAmount())); + if (less) { + throw new BadRequestException(StrUtil.format("{}({})不能小于已挂账金额({})", "挂账额度", "creditAmount", entity.getOwedAmount())); + } + BeanUtil.copyProperties(dto, entity, CopyOptions.create().setIgnoreNullValue(false).setIgnoreProperties("repaymentMethod", "accountBalance")); + return super.updateById(entity); + } + + @Override + public void delete(String id) { + try { + Assert.notEmpty(id, "{}不能为空", "id"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + super.update(Wrappers.lambdaUpdate().set(TbCreditBuyer::getDelFlag, 1).eq(TbCreditBuyer::getId, id)); + } + + @Override + public TbCreditBuyer getById(String id) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbCreditBuyer::getId, id); + wrapper.select(TbCreditBuyer::getId, TbCreditBuyer::getShopId, TbCreditBuyer::getStatus, TbCreditBuyer::getDebtor, TbCreditBuyer::getMobile, TbCreditBuyer::getPosition, TbCreditBuyer::getCreditAmount, TbCreditBuyer::getRepaymentMethod, TbCreditBuyer::getPaymentMethod, TbCreditBuyer::getRemark, TbCreditBuyer::getDelFlag, TbCreditBuyer::getOwedAmount, TbCreditBuyer::getAccumulateAmount, TbCreditBuyer::getShopName, TbCreditBuyer::getResponsiblePerson, TbCreditBuyer::getAccountBalance); + return baseMapper.selectOne(wrapper); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Map repayment(Map params) { + MapProxy mapProxy = MapProxy.create(params); + // 还款金额 + BigDecimal repaymentAmount = mapProxy.getBigDecimal("repaymentAmount"); + TbCreditBuyer param = BeanUtil.toBean(params, TbCreditBuyer.class); + try { + Assert.notEmpty(param.getId(), "{}不能为空", "id"); + Assert.notNull(repaymentAmount, "{}({})不能为空", "还款金额", "repaymentAmount"); + Assert.notNull(param.getPaymentMethod(), "{}({})不能为空", "支付方式", "paymentMethod"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + TbCreditBuyer entity = getById(param.getId()); + if (entity == null) { + throw new BadRequestException("挂账人不存在"); + } + Integer delFlag = entity.getDelFlag(); + if (delFlag == 1) { + throw new BadRequestException("挂账人已删除"); + } + if (!"total".equals(entity.getRepaymentMethod())) { + throw new BadRequestException("此挂账人不能以【按总账户还款】进行还款"); + } + if (NumberUtil.isLess(repaymentAmount, BigDecimal.ZERO)) { + throw new BadRequestException("还款金额不能小于0"); + } + BigDecimal initRepaymentAmount = NumberUtil.add(repaymentAmount, BigDecimal.ZERO); + // 已挂账金额 + BigDecimal owedAmount = entity.getOwedAmount(); + if (NumberUtil.equals(owedAmount, BigDecimal.ZERO)) { + entity.setAccountBalance(NumberUtil.add(entity.getAccountBalance(), repaymentAmount)); + super.updateById(entity); + TbCreditPaymentRecord record = new TbCreditPaymentRecord(); + record.setCreditBuyerId(param.getId()); + record.setRepaymentAmount(repaymentAmount); + record.setPaymentMethod(param.getPaymentMethod()); + record.setCreateTime(new Date()); + record.setPaymentTime(new Date()); + record.setRemark(param.getRemark()); + tbCreditPaymentRecordMapper.insert(record); + Map result = new HashMap<>(3); + result.put("repaymentCount", 0); + result.put("repaymentAmount", repaymentAmount); + result.put("repaymentMsg", StrUtil.format("账单无需还款,{}元已转储至余额。", repaymentAmount)); + return result; + } + // 转存余额 + BigDecimal rechargeAmount = BigDecimal.ZERO; + if (NumberUtil.isGreater(repaymentAmount, owedAmount)) { + rechargeAmount = NumberUtil.sub(repaymentAmount, owedAmount); + entity.setAccountBalance(NumberUtil.add(entity.getAccountBalance(), rechargeAmount)); + super.updateById(entity); + TbCreditPaymentRecord record = new TbCreditPaymentRecord(); + record.setCreditBuyerId(param.getId()); + record.setRepaymentAmount(rechargeAmount); + record.setPaymentMethod(param.getPaymentMethod()); + record.setCreateTime(new Date()); + record.setPaymentTime(new Date()); + record.setRemark(param.getRemark()); + tbCreditPaymentRecordMapper.insert(record); + } + + // 校验完毕,可以批量还款 + Map where = new HashMap<>(); + where.put("creditBuyerId", param.getId()); + where.put("statusList", Arrays.asList("unpaid", "partial")); + List list = tbCreditBuyerOrderMapper.getList(where); + if (CollUtil.isEmpty(list)) { + throw new BadRequestException("没有需要还款的订单"); + } + int repaymentCount = 0; + List orderList = list.stream().sorted(Comparator.comparing(CreditBuyerOrderDTO::getOrderId)).collect(Collectors.toList()); + for (CreditBuyerOrderDTO dto : orderList) { + // 未付款金额 + BigDecimal unpaidAmount = dto.getUnpaidAmount(); + // 记录还款记录 + TbCreditPaymentRecord record = new TbCreditPaymentRecord(); + if (NumberUtil.isGreaterOrEqual(repaymentAmount, unpaidAmount)) { + // 还全额 + tbCreditBuyerOrderMapper.update(Wrappers.lambdaUpdate() + .eq(TbCreditBuyerOrder::getStatus, dto.getStatus()) + .eq(TbCreditBuyerOrder::getId, dto.getId()) + .eq(TbCreditBuyerOrder::getOrderId, dto.getOrderId()) + .eq(TbCreditBuyerOrder::getCreditBuyerId, dto.getCreditBuyerId()) + .eq(TbCreditBuyerOrder::getPaidAmount, dto.getPaidAmount()) + .set(TbCreditBuyerOrder::getStatus, "paid") + .set(TbCreditBuyerOrder::getPaidAmount, NumberUtil.add(dto.getPaidAmount(), unpaidAmount)) + .set(TbCreditBuyerOrder::getRemark, param.getRemark()) + .set(TbCreditBuyerOrder::getLastPaymentMethod, param.getPaymentMethod()) + .set(TbCreditBuyerOrder::getLastPaymentTime, new Date()) + ); + record.setRepaymentAmount(unpaidAmount); + repaymentAmount = NumberUtil.sub(repaymentAmount, unpaidAmount); + } else if (NumberUtil.isLess(repaymentAmount, unpaidAmount)) { + // 还部分 + tbCreditBuyerOrderMapper.update(Wrappers.lambdaUpdate() + .eq(TbCreditBuyerOrder::getStatus, dto.getStatus()) + .eq(TbCreditBuyerOrder::getId, dto.getId()) + .eq(TbCreditBuyerOrder::getOrderId, dto.getOrderId()) + .eq(TbCreditBuyerOrder::getCreditBuyerId, dto.getCreditBuyerId()) + .eq(TbCreditBuyerOrder::getPaidAmount, dto.getPaidAmount()) + .set(TbCreditBuyerOrder::getStatus, "partial") + .set(TbCreditBuyerOrder::getPaidAmount, NumberUtil.add(dto.getPaidAmount(), repaymentAmount)) + .set(TbCreditBuyerOrder::getRemark, param.getRemark()) + .set(TbCreditBuyerOrder::getLastPaymentMethod, param.getPaymentMethod()) + .set(TbCreditBuyerOrder::getLastPaymentTime, new Date()) + ); + record.setRepaymentAmount(repaymentAmount); + repaymentAmount = BigDecimal.ZERO; + } + record.setCreditBuyerId(dto.getCreditBuyerId()); + record.setOrderId(dto.getOrderId()); + record.setPaymentMethod(param.getPaymentMethod()); + record.setCreateTime(new Date()); + record.setPaymentTime(new Date()); + record.setRemark(param.getRemark()); + tbCreditPaymentRecordMapper.insert(record); + repaymentCount++; + if (NumberUtil.equals(repaymentAmount, BigDecimal.ZERO)) { + break; + } + } + Map result = new HashMap<>(5); + BigDecimal payAmount = NumberUtil.sub(initRepaymentAmount, repaymentAmount); + result.put("repaymentCount", repaymentCount); + result.put("repaymentAmount", initRepaymentAmount); + result.put("payAmount", payAmount); + result.put("rechargeAmount", rechargeAmount); + result.put("repaymentMsg", StrUtil.format("共计还款{}笔,还款金额:{}元,支付欠款:{}元,转存余额:{}元,当前余额:{}元。", repaymentCount, initRepaymentAmount, payAmount, rechargeAmount, entity.getAccountBalance())); + return result; + } + + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditPaymentRecordServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditPaymentRecordServiceImpl.java new file mode 100644 index 00000000..c30d30a0 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCreditPaymentRecordServiceImpl.java @@ -0,0 +1,48 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord; +import cn.ysk.cashier.mybatis.mapper.TbCreditPaymentRecordMapper; +import cn.ysk.cashier.mybatis.service.TbCreditPaymentRecordService; +import cn.ysk.cashier.utils.PageUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 挂账账单付款记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-20 + */ +@Service +public class TbCreditPaymentRecordServiceImpl extends ServiceImpl implements TbCreditPaymentRecordService { + + private LambdaQueryWrapper getWrapper(Map params) { + TbCreditPaymentRecord param = BeanUtil.toBean(params, TbCreditPaymentRecord.class); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbCreditPaymentRecord::getCreditBuyerId, param.getCreditBuyerId()); + wrapper.eq(param.getOrderId() != null, TbCreditPaymentRecord::getOrderId, param.getOrderId()); + wrapper.like(StrUtil.isNotEmpty(param.getPaymentMethod()), TbCreditPaymentRecord::getPaymentMethod, param.getPaymentMethod()); + wrapper.orderByDesc(TbCreditPaymentRecord::getId); + return wrapper; + } + + @Override + public Map page(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + LambdaQueryWrapper wrapper = getWrapper(params); + wrapper.orderByDesc(TbCreditPaymentRecord::getId); + Page page = super.page(new Page<>(pageNum, pageSize), wrapper); + return PageUtil.toPlusPage(page.getRecords(), Convert.toInt(page.getTotal())); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsExchangeRecordServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsExchangeRecordServiceImpl.java index 00071ce7..ccb65cda 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsExchangeRecordServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsExchangeRecordServiceImpl.java @@ -250,7 +250,7 @@ public class TbPointsExchangeRecordServiceImpl extends ServiceImpl= 5")); + .last("and TIMESTAMPDIFF(MINUTE, NOW(), create_time) >= 5")); } } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java new file mode 100644 index 00000000..13305a4d --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopSyncInfoServiceImpl.java @@ -0,0 +1,535 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateTime; +import cn.ysk.cashier.cons.domain.TbConsInfo; +import cn.ysk.cashier.cons.domain.TbConsType; +import cn.ysk.cashier.cons.domain.TbProskuCon; +import cn.ysk.cashier.cons.repository.TbConsInfoRepository; +import cn.ysk.cashier.cons.repository.TbConsTypeRepository; +import cn.ysk.cashier.cons.repository.TbProskuConRepository; +import cn.ysk.cashier.dto.TbShopSyncInfoQueryCriteria; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.entity.TbShopSyncInfo; +import cn.ysk.cashier.mybatis.mapper.TbShopSyncInfoMapper; +import cn.ysk.cashier.mybatis.service.TbShopSyncInfoService; +import cn.ysk.cashier.pojo.order.TbOrderInfo; +import cn.ysk.cashier.pojo.product.*; +import cn.ysk.cashier.pojo.shop.TbShopUnit; +import cn.ysk.cashier.repository.product.*; +import cn.ysk.cashier.repository.shop.TbShopUnitRepository; +import cn.ysk.cashier.utils.*; +import cn.ysk.cashier.vo.ProductGroupVo; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.gson.JsonObject; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.persistence.criteria.Predicate; +import java.math.BigDecimal; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static cn.ysk.cashier.utils.StringCodeUtil.TYPE.LETTER_CAPITAL_NUMBER; + +/** + * 店铺信息同步记录表(TbShopSyncInfo)表服务实现类 + * + * @author ww + * @since 2024-11-25 16:46:12 + */ +@Slf4j +@Service +@Transactional +public class TbShopSyncInfoServiceImpl extends ServiceImpl implements TbShopSyncInfoService { + + + @Autowired + private ApplicationContext applicationContext; + + @Autowired + private TbShopSyncInfoMapper tbShopSyncInfomapper; + //单位 + @Autowired + private TbShopUnitRepository unitRepository; + //规格 + @Autowired + private TbProductSpecRepository specRepository; + //分组 + @Autowired + private TbProductGroupRepository groupRepository; + //分类 + @Autowired + private TbShopCategoryRepository categoryRepository; + //商品 + @Autowired + private TbProductRepository productRepository; + @Autowired + private TbProductSkuRepository skuRepository; + @Autowired + private TbProductSkuResultRepository skuResultRepository; + + //耗材 + @Autowired + private TbConsInfoRepository consRepository; + @Autowired + private TbConsTypeRepository consTypeRepository; + @Autowired + private TbProskuConRepository proSkuConRepository; + + + @Override + public TbShopSyncInfo queryByShopId(TbShopSyncInfoQueryCriteria criteria) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("point_shop_id", criteria.getPointShopId()); + wrapper.orderByDesc("sync_time"); + TbShopSyncInfo tbShopSyncInfo = tbShopSyncInfomapper.selectOne(wrapper); + return tbShopSyncInfo; + } + + @Async + @Override + public void sync(TbShopSyncInfo tbShopSyncInfo) { + Map units; + Map specs; + Map cateGorys; + Map groups; + Map pros = new HashMap<>(); + Map skus = new HashMap<>(); + Map conTypes; + Map consInfos = new HashMap<>(); + Map consPros = new HashMap<>(); + Integer skuResults = 0; + TbShopSyncInfoServiceImpl self = applicationContext.getBean(TbShopSyncInfoServiceImpl.class); + + try { + List> futures = new ArrayList<>(); + List> futures2 = new ArrayList<>(); + if (tbShopSyncInfo.getProduct() != null && tbShopSyncInfo.getProduct() > 0) { + CompletableFuture> futureUnit = self.syncUnit(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + CompletableFuture> futureSpec = self.syncSpec(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + CompletableFuture> futureCate = self.syncCategory(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + futures.add(futureUnit); + futures.add(futureSpec); + futures.add(futureCate); + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); + + units = futureUnit.get(); + tbShopSyncInfo.setProUnit(units.size()); + + specs = futureSpec.get(); + tbShopSyncInfo.setProSpec(specs.size()); + + cateGorys = futureCate.get(); + tbShopSyncInfo.setProCategory(cateGorys.size()); + + CompletableFuture> futurePros = self.syncProduct(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId(), units, specs, cateGorys); + pros = futurePros.get(); + tbShopSyncInfo.setProduct(pros.size()); + + self.syncGroupPackage(tbShopSyncInfo.getPointShopId(), pros, skus); + CompletableFuture> futureGroup = self.syncGroup(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId(), pros); + CompletableFuture> futureSkus = self.syncSku(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId(), pros); + CompletableFuture futureSkuResults = self.syncSkuResult(pros); + futures2.add(futureGroup); + futures2.add(futureSkus); + futures2.add(futureSkuResults); + + CompletableFuture.allOf(futures2.toArray(new CompletableFuture[0])).join(); + + groups = futureGroup.get(); + tbShopSyncInfo.setProGroup(groups.size()); + + skus = futureSkus.get(); + tbShopSyncInfo.setProSku(skus.size()); + + skuResults = futureSkuResults.get(); + tbShopSyncInfo.setProSkuResult(skuResults); + } else { + if (tbShopSyncInfo.getProUnit() != null && tbShopSyncInfo.getProUnit() > 0) { + CompletableFuture> futureUnit = self.syncUnit(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + units = futureUnit.get(); + tbShopSyncInfo.setProUnit(units.size()); + } + if (tbShopSyncInfo.getProCategory() != null && tbShopSyncInfo.getProCategory() > 0) { + CompletableFuture> futureCate = self.syncCategory(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + cateGorys = futureCate.get(); + tbShopSyncInfo.setProCategory(cateGorys.size()); + } + if (tbShopSyncInfo.getProSpec() != null && tbShopSyncInfo.getProSpec() > 0) { + CompletableFuture> futureSpec = self.syncSpec(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + specs = futureSpec.get(); + tbShopSyncInfo.setProSpec(specs.size()); + } + } + + if (tbShopSyncInfo.getConsInfo() != null && tbShopSyncInfo.getConsInfo() > 0) { + CompletableFuture> futureConTypes = self.syncConsType(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + conTypes = futureConTypes.get(); + tbShopSyncInfo.setConsType(conTypes.size()); + + CompletableFuture> futureConsInfos = self.syncCons(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId(), conTypes); + consInfos = futureConsInfos.get(); + tbShopSyncInfo.setConsInfo(consInfos.size()); + } else if (tbShopSyncInfo.getConsType() != null && tbShopSyncInfo.getConsType() > 0) { + CompletableFuture> futureConTypes = self.syncConsType(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId()); + conTypes = futureConTypes.get(); + tbShopSyncInfo.setConsType(conTypes.size()); + } + + if (tbShopSyncInfo.getConsPro() != null && tbShopSyncInfo.getConsPro() > 0 + && tbShopSyncInfo.getConsInfo() != null && tbShopSyncInfo.getConsInfo() > 0 + && tbShopSyncInfo.getProduct() != null && tbShopSyncInfo.getProduct() > 0) { + CompletableFuture> mapCompletableFuture = self.syncConsPro(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId(), consInfos, pros, skus); + consPros = mapCompletableFuture.get(); + tbShopSyncInfo.setConsPro(consPros.size()); + } + tbShopSyncInfo.setSyncTime(new Date()); + tbShopSyncInfo.setStatus(2); + tbShopSyncInfomapper.updateById(tbShopSyncInfo); + } catch (Exception e) { + tbShopSyncInfo.setProSpec(0); + tbShopSyncInfo.setProGroup(0); + tbShopSyncInfo.setProUnit(0); + tbShopSyncInfo.setProCategory(0); + tbShopSyncInfo.setProSkuResult(0); + tbShopSyncInfo.setProSku(0); + tbShopSyncInfo.setProduct(0); + + tbShopSyncInfo.setConsType(0); + tbShopSyncInfo.setConsInfo(0); + tbShopSyncInfo.setConsPro(0); + + tbShopSyncInfo.setSyncTime(new Date()); + tbShopSyncInfo.setStatus(0); + tbShopSyncInfomapper.updateById(tbShopSyncInfo); + log.error("数据同步失败", e); + } + } + + @Override + public void clear(TbShopSyncInfo tbShopSyncInfo) { + unitRepository.clearShopUnit(tbShopSyncInfo.getPointShopId().toString()); + specRepository.clearShopSpec(tbShopSyncInfo.getPointShopId().toString()); + groupRepository.clearShopGroup(tbShopSyncInfo.getPointShopId()); + categoryRepository.clearShopCategory(tbShopSyncInfo.getPointShopId().toString()); + List products = productRepository.selectByShopId(tbShopSyncInfo.getPointShopId().toString()); + List collect = products.stream().map(TbProduct::getId).collect(Collectors.toList()); + skuResultRepository.deleteAllByIdInBatch(collect); + productRepository.clearShopPro(tbShopSyncInfo.getPointShopId().toString()); + skuRepository.clearShopSku(tbShopSyncInfo.getPointShopId().toString()); + consRepository.clearShopCons(tbShopSyncInfo.getPointShopId()); + consTypeRepository.clearShopConType(tbShopSyncInfo.getPointShopId()); + List tbProskuCons = proSkuConRepository.searchConsProByShopId(tbShopSyncInfo.getPointShopId()); + List proCons = tbProskuCons.stream().map(TbProskuCon::getId).collect(Collectors.toList()); + proSkuConRepository.deleteAllByIdInBatch(proCons); + + proSkuConRepository.clearShopConPro(tbShopSyncInfo.getPointShopId()); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("point_shop_id", tbShopSyncInfo.getPointShopId()); + tbShopSyncInfomapper.delete(wrapper); + } + + //单位 + @Async + public CompletableFuture> syncUnit(Integer sourceShopId, Integer pointShopId) { + CompletableFuture> future = new CompletableFuture<>(); + Map unitMap = new HashMap<>(); + unitRepository.searchUnitByShopId(sourceShopId.toString()).forEach(tbShopUnit -> { + Integer sourceUnitId = tbShopUnit.getId(); + TbShopUnit unitNew = new TbShopUnit(); + unitNew.copy(tbShopUnit); + unitNew.setId(null); + unitNew.setShopId(pointShopId.toString()); + unitRepository.save(unitNew); + unitMap.put(sourceUnitId, unitNew.getId()); + }); + future.complete(unitMap); + return future; + } + + //规格 + @Async + public CompletableFuture> syncSpec(Integer sourceShopId, Integer pointShopId) { + log.info("规格同步 "+System.currentTimeMillis()); + CompletableFuture> future = new CompletableFuture<>(); + Map specMap = new HashMap<>(); + specRepository.searchSpecByShopId(sourceShopId.toString()).forEach(tbProductSpec -> { + Integer sourceSpecId = tbProductSpec.getId(); + TbProductSpec tbProductSpecNew = new TbProductSpec(); + tbProductSpecNew.copy(tbProductSpec); + tbProductSpecNew.setId(null); + tbProductSpecNew.setShopId(pointShopId.toString()); + specRepository.save(tbProductSpecNew); + specMap.put(sourceSpecId, tbProductSpec.getId()); + }); + future.complete(specMap); + return future; + } + + // 分类 + @Async + public CompletableFuture> syncCategory(Integer sourceShopId, Integer pointShopId) { + log.info("分类同步 "+System.currentTimeMillis()); + CompletableFuture> future = new CompletableFuture<>(); + Map categoryMap = new HashMap<>(); + List tbShopCategories = categoryRepository.searchCategoryByShopId(sourceShopId.toString()); + List treeIds = new ArrayList<>(); + for (TbShopCategory tbShopCategory : tbShopCategories) { + treeIds.add(tbShopCategory.getId()); + + Integer sourceCategoryId = tbShopCategory.getId(); + + TbShopCategory tbShopCategoryNew = new TbShopCategory(); + tbShopCategoryNew.copy(tbShopCategory); + tbShopCategoryNew.setId(null); + tbShopCategoryNew.setShopId(pointShopId.toString()); + tbShopCategoryNew.setTree(null); + tbShopCategoryNew.setPid(""); + categoryRepository.save(tbShopCategoryNew); + categoryMap.put(sourceCategoryId, tbShopCategoryNew.getId()); + } + if (CollectionUtil.isNotEmpty(treeIds)) { + List children = categoryRepository.findChildren(treeIds); + for (TbShopCategory child : children) { + Integer sourceCategoryId = child.getId(); + TbShopCategory tbShopCategoryNew = new TbShopCategory(); + tbShopCategoryNew.copy(child); + tbShopCategoryNew.setId(null); + tbShopCategoryNew.setShopId(pointShopId.toString()); + tbShopCategoryNew.setTree(categoryMap.get(child.getTree())); + tbShopCategoryNew.setPid(StringUtils.isNotBlank(child.getPid()) ? categoryMap.get(Integer.valueOf(child.getPid())).toString() : ""); + categoryRepository.save(tbShopCategoryNew); + categoryMap.put(sourceCategoryId, tbShopCategoryNew.getId()); + } + } + future.complete(categoryMap); + return future; + } + + @Async + public CompletableFuture> syncProduct(Integer sourceShopId, Integer pointShopId, Map units, + Map specs, Map cateGorys) { + CompletableFuture> future = new CompletableFuture<>(); + String cateGory = ""; + if(CollectionUtil.isNotEmpty(cateGorys)){ + cateGory = cateGorys.keySet().stream().findFirst().get().toString(); + } + + Map proMap = new HashMap<>(); + List products = productRepository.findByShopId(sourceShopId.toString()); + if(CollectionUtil.isNotEmpty(products)){ + for (TbProduct tbProduct : products) { + Integer sourceSpecId = tbProduct.getId(); + TbProduct tbProductNew = new TbProduct(); + tbProductNew.copy(tbProduct); + + tbProductNew.setId(null); + tbProductNew.setShopId(pointShopId.toString()); + if(StringUtils.isNotBlank(tbProduct.getCategoryId()) && cateGorys.containsKey(Integer.valueOf(tbProduct.getCategoryId()))){ + tbProductNew.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId()) ? cateGorys.get(Integer.valueOf(tbProduct.getCategoryId())).toString() : ""); + }else { + tbProductNew.setCategoryId(cateGory); + } + + tbProductNew.setSpecId(tbProduct.getSpecId() != null ? specs.get(tbProduct.getSpecId()) : null); + tbProductNew.setUnitId(tbProduct.getUnitId() != null ? units.get(tbProduct.getUnitId()) : null); + tbProductNew.setStockNumber(0); + + productRepository.save(tbProductNew); + proMap.put(sourceSpecId, tbProductNew.getId()); + } + } + future.complete(proMap); + return future; + } + + @Async + public CompletableFuture> syncGroup(Integer sourceShopId, Integer pointShopId, Map pros) { + CompletableFuture> future = new CompletableFuture<>(); + Map groupMap = new HashMap<>(); + groupRepository.searchGroupByShopId(sourceShopId).forEach(tbProductGroup -> { + Integer groupId = tbProductGroup.getId(); + TbProductGroup tbProductGroupNew = new TbProductGroup(); + tbProductGroupNew.copy(tbProductGroup); + tbProductGroupNew.setId(null); + tbProductGroupNew.setShopId(pointShopId); + tbProductGroupNew.setUseTime(0); + tbProductGroupNew.setProductIds(replaceProIds(tbProductGroup.getProductIds(), pros)); + groupRepository.save(tbProductGroupNew); + groupMap.put(groupId, tbProductGroupNew.getId()); + }); + future.complete(groupMap); + return future; + } + + //分组 + @Async + public void syncGroupPackage(Integer shopId, Map pros, Map skus) { + productRepository.findPackageByShopId(shopId.toString()).forEach(tbProduct -> { + if(StringUtils.isNotBlank(tbProduct.getGroupSnap())){ + tbProduct.setProGroupVo(JSONUtil.parseJSONStrTList(tbProduct.getGroupSnap(), ProductGroupVo.class)); + if (tbProduct.getProGroupVo() != null) { + tbProduct.getProGroupVo().forEach(proGroupVo -> { + proGroupVo.getGoods().forEach(goods -> { + if (pros.containsKey(goods.getProId())) { + if (goods.getSkuId() != null && skus.containsKey(goods.getSkuId())) { + goods.setProId(pros.get(goods.getProId())); + goods.setSkuId(skus.get(goods.getSkuId())); + } else { + goods.setProId(pros.get(goods.getProId())); + } + } + }); + proGroupVo.setCount(proGroupVo.getGoods().size()); + if (proGroupVo.getNumber() != null && proGroupVo.getNumber() > 0) { + if (proGroupVo.getNumber() > proGroupVo.getCount()) { + proGroupVo.setNumber(proGroupVo.getCount()); + } + } + }); + tbProduct.setGroupSnap(ListUtil.listToJsonString(tbProduct.getProGroupVo())); + productRepository.save(tbProduct); + } + } + }); + } + + //分组 + @Async + public CompletableFuture> syncSku(Integer sourceShopId, Integer pointShopId, Map pros) { + CompletableFuture> future = new CompletableFuture<>(); + Map skuMap = new HashMap<>(); + skuRepository.searchSkuByShopId(sourceShopId.toString()).forEach(tbProductSku -> { + Integer productId = Integer.valueOf(tbProductSku.getProductId()); + if (pros.containsKey(productId)) { + Integer sourceSkuId = tbProductSku.getId(); + TbProductSku tbProductSkuNew = new TbProductSku(); + tbProductSkuNew.copy(tbProductSku); + tbProductSkuNew.setId(null); + tbProductSkuNew.setShopId(pointShopId.toString()); + tbProductSkuNew.setProductId(pros.get(productId).toString()); + skuRepository.save(tbProductSkuNew); + skuMap.put(sourceSkuId, tbProductSkuNew.getId()); + } + }); + future.complete(skuMap); + return future; + } + + @Async + public CompletableFuture syncSkuResult(Map pros) { + CompletableFuture future = new CompletableFuture<>(); + List skuResults = skuResultRepository.findAll((root, criteriaQuery, criteriaBuilder) -> { + Predicate predicate = root.get("id").in(pros.keySet()); + return predicate; + }); + skuResults.forEach(tbProductSkuResult -> { + TbProductSkuResult tbProductSkuResultNew = new TbProductSkuResult(); + tbProductSkuResultNew.copy(tbProductSkuResult); + tbProductSkuResultNew.setId(pros.get(tbProductSkuResult.getId())); + skuResultRepository.save(tbProductSkuResultNew); + }); + future.complete(skuResults.size()); + return future; + } + + @Async + public CompletableFuture> syncConsType(Integer sourceShopId, Integer pointShopId) { + CompletableFuture> future = new CompletableFuture<>(); + Map consTypeMap = new HashMap<>(); + + List tbConsTypes = consTypeRepository.searchConsTypeByShopId(sourceShopId); + for (TbConsType tbConsType : tbConsTypes) { + Integer sourceConsTypeId = tbConsType.getId(); + TbConsType tbConsTypeNew = new TbConsType(); + tbConsTypeNew.copy(tbConsType); + tbConsTypeNew.setId(null); + tbConsTypeNew.setShopId(pointShopId); + consTypeRepository.save(tbConsTypeNew); + consTypeMap.put(sourceConsTypeId, tbConsTypeNew.getId()); + } + + future.complete(consTypeMap); + return future; + } + + // 耗材 + @Async + public CompletableFuture> syncCons(Integer sourceShopId, Integer pointShopId, Map conTypes) { + CompletableFuture> future = new CompletableFuture<>(); + Map consMap = new HashMap<>(); + List tbConsInfos = consRepository.searchConsInfoByShopId(sourceShopId); + for (TbConsInfo tbConsInfo : tbConsInfos) { + Integer sourceConsId = tbConsInfo.getId(); + TbConsInfo tbConsInfoNew = new TbConsInfo(); + tbConsInfoNew.copy(tbConsInfo); + tbConsInfoNew.setId(null); + tbConsInfoNew.setShopId(pointShopId); + tbConsInfoNew.setConTypeId(conTypes.get(tbConsInfo.getConTypeId())); + tbConsInfoNew.setConCode(StringCodeUtil.getRandom(8, LETTER_CAPITAL_NUMBER)); + tbConsInfoNew.setStockNumber(BigDecimal.ZERO); + tbConsInfoNew.setStockConsume(BigDecimal.ZERO); + consRepository.save(tbConsInfoNew); + consMap.put(sourceConsId, tbConsInfoNew.getId()); + } + future.complete(consMap); + return future; + } + + @Async + public CompletableFuture> syncConsPro(Integer sourceShopId, Integer pointShopId, Map consMap, Map proMap, Map skuMap) { + CompletableFuture> future = new CompletableFuture<>(); + Map proSkuConMap = new HashMap<>(); + proSkuConRepository.searchConsProByShopId(sourceShopId).forEach(tbConsPro -> { + if (consMap.containsKey(tbConsPro.getConInfoId()) && proMap.containsKey(tbConsPro.getProductId()) && skuMap.containsKey(tbConsPro.getProductSkuId())) { + Integer sourceConsProId = tbConsPro.getId(); + TbProskuCon tbConsProNew = new TbProskuCon(); + tbConsProNew.copy(tbConsPro); + tbConsProNew.setId(null); + tbConsProNew.setShopId(pointShopId); + tbConsProNew.setConInfoId(consMap.get(tbConsPro.getConInfoId())); + tbConsProNew.setProductId(proMap.get(tbConsPro.getProductId())); + if (tbConsPro.getProductSkuId() > 0) { + tbConsProNew.setProductSkuId(skuMap.get(tbConsPro.getProductSkuId())); + } + proSkuConRepository.save(tbConsProNew); + proSkuConMap.put(sourceConsProId, tbConsProNew.getId()); + } + }); + future.complete(proSkuConMap); + return future; + } + + /** + * 分组关联商品 重组 如果绑定的商品Id 不存在 则抛弃 + */ + public static String replaceProIds(String proStr, Map pros) { + if (StringUtils.isNotBlank(proStr) && !"[]".equals(proStr)) { + proStr = proStr.substring(1, proStr.length() - 1); + String[] numbersStr = proStr.split(","); + String result = Stream.of(numbersStr) + .map(Integer::parseInt) + .filter(number -> pros.containsKey(number)) + .map(pros::get) + .map(Object::toString) + .collect(Collectors.joining(",", "[", "]")); + return result; + } + return "[]"; + } +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java new file mode 100644 index 00000000..f0344229 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopTableBookingServiceImpl.java @@ -0,0 +1,302 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.dto.booking.ShopTableBookingDTO; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.entity.TbShopTableBooking; +import cn.ysk.cashier.mybatis.mapper.MpShopAreaMapper; +import cn.ysk.cashier.mybatis.mapper.MpShopTableMapper; +import cn.ysk.cashier.mybatis.mapper.TbShopTableBookingMapper; +import cn.ysk.cashier.mybatis.service.TbShopTableBookingService; +import cn.ysk.cashier.pojo.shop.TbShopArea; +import cn.ysk.cashier.pojo.shop.TbShopInfo; +import cn.ysk.cashier.pojo.shop.TbShopTable; +import cn.ysk.cashier.repository.shop.TbShopInfoRepository; +import cn.ysk.cashier.utils.PageUtil; +import cn.ysk.cashier.utils.SecurityUtils; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 店铺台桌预订 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-11-21 + */ +@Service +public class TbShopTableBookingServiceImpl extends ServiceImpl implements TbShopTableBookingService { + + private static final Map BOOKING_TYPE = MapUtil.builder("lunch", "午餐") + .put("dinner", "晚餐") + .build(); + + @Resource + private TbShopInfoRepository tbShopInfoRepository; + + @Resource + private MpShopTableMapper mpShopTableMapper; + + @Resource + private MpShopAreaMapper mpShopAreaMapper; + + private LambdaQueryWrapper getWrapper(Map params) { + MapProxy mapProxy = MapProxy.create(params); + String keywords = mapProxy.getStr("keywords"); + TbShopTableBooking param = BeanUtil.toBean(params, TbShopTableBooking.class); + + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbShopTableBooking::getShopId, param.getShopId()); + wrapper.eq(param.getId() != null, TbShopTableBooking::getId, param.getId()); + wrapper.like(StrUtil.isNotEmpty(param.getOrderNo()), TbShopTableBooking::getOrderNo, param.getOrderNo()); + wrapper.eq(param.getBookingDate() != null, TbShopTableBooking::getBookingDate, param.getBookingDate()); + wrapper.eq(StrUtil.isNotEmpty(param.getBookingType()), TbShopTableBooking::getBookingType, param.getBookingType()); + wrapper.like(StrUtil.isNotEmpty(param.getDiningType()), TbShopTableBooking::getDiningType, param.getDiningType()); + wrapper.eq(param.getFocus() != null, TbShopTableBooking::getFocus, param.getFocus()); + wrapper.eq(param.getReceiveMarketingSms() != null, TbShopTableBooking::getReceiveMarketingSms, param.getReceiveMarketingSms()); + wrapper.eq(param.getReceiveMarketingSms() != null, TbShopTableBooking::getReceiveMarketingSms, param.getReceiveMarketingSms()); + wrapper.eq(param.getStatus() != null, TbShopTableBooking::getStatus, param.getStatus()); + if (StrUtil.isNotEmpty(keywords)) { + wrapper.nested(i -> i.like(TbShopTableBooking::getBookingPerson, keywords).or().like(TbShopTableBooking::getPhoneNumber, keywords)); + } + wrapper.eq(TbShopTableBooking::getDelFlag, 0); + wrapper.orderByDesc(TbShopTableBooking::getFocus); + wrapper.orderByDesc(TbShopTableBooking::getStatus); + wrapper.orderByAsc(TbShopTableBooking::getBookingTime); + wrapper.orderByDesc(TbShopTableBooking::getId); + return wrapper; + } + + @Override + public Map page(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + LambdaQueryWrapper wrapper = getWrapper(params); + + Page page = super.page(new Page<>(pageNum, pageSize), wrapper); + return PageUtil.toPlusPage(page.getRecords(), Convert.toInt(page.getTotal())); + } + + private void commonVerify(TbShopTableBooking entity) { + try { + Assert.notNull(entity.getShopTableId(), "{}({})不能为空", "台桌id", "shopTableId"); + Assert.notNull(entity.getShopId(), "{}({})不能为空", "店铺id", "shopId"); + Assert.notNull(entity.getBookingDate(), "{}({})不能为空", "预约日期", "bookingDate"); + Assert.notEmpty(entity.getBookingType(), "{}({})不能为空", "预订类型(午餐/晚餐)", "bookingType"); + Assert.notNull(entity.getDinerNum(), "{}({})不能为空", "用餐人数", "dinerNum"); + Assert.notEmpty(entity.getPhoneNumber(), "{}({})不能为空", "电话号码", "phoneNumber"); + Assert.notEmpty(entity.getBookingPerson(), "{}({})不能为空", "订餐人", "bookingPerson"); + Assert.notNull(entity.getGender(), "{}({})不能为空", "性别/称呼", "gender"); + Assert.notNull(entity.getBookingTime(), "{}({})不能为空", "约定时间", "bookingTime"); + Assert.notEmpty(entity.getDiningType(), "{}({})不能为空", "用餐类型", "diningType"); + Assert.notNull(entity.getFocus(), "{}({})不能为空", "重点关注", "focus"); + Assert.notNull(entity.getReceiveMarketingSms(), "{}({})不能为空", "接收营销短信", "receiveMarketingSms"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + } + + @Override + public String booking(TbShopTableBooking entity) { + commonVerify(entity); + if (DateUtil.compare(entity.getBookingTime(), new Date()) < 0) { + throw new BadRequestException("预订日期(bookingDate)不能小于今天"); + } + long existCount = baseMapper.selectCount(Wrappers.lambdaQuery() + .eq(TbShopTableBooking::getShopId, entity.getShopId()) + .eq(TbShopTableBooking::getShopTableId, entity.getShopTableId()) + .eq(TbShopTableBooking::getBookingDate, entity.getBookingDate()) + .eq(TbShopTableBooking::getBookingType, entity.getBookingType()) + .ne(TbShopTableBooking::getStatus, -1) + .eq(TbShopTableBooking::getDelFlag, 0) + ); + if (existCount > 0) { + throw new BadRequestException(StrUtil.format("该台桌{}档在{}已被预订", BOOKING_TYPE.get(entity.getBookingType()), DateUtil.formatDate(entity.getBookingDate()))); + } + String nextId = IdUtil.getSnowflakeNextIdStr(); + String seq = StrUtil.sub(nextId, -5, nextId.length()); + String orderNo = DateUtil.format(new Date(), "yyMMddHHmmss") + seq; + entity.setOrderNo("BK" + orderNo); + entity.setStatus(20); + entity.setCreateTime(new Date()); + entity.setCreateUserName(SecurityUtils.getCurrentUserNickName()); + entity.setDelFlag(0); + super.save(entity); + return entity.getOrderNo(); + } + + @Override + public boolean update(TbShopTableBooking dto) { + if (dto.getId() == null) { + throw new BadRequestException("id不能为空"); + } + commonVerify(dto); + TbShopTableBooking entity = super.getById(dto.getId()); + if (entity == null) { + throw new BadRequestException("预订信息不存在"); + } + if (DateUtil.compare(dto.getBookingTime(), new Date()) < 0) { + throw new BadRequestException("预订日期(bookingDate)不能小于今天"); + } + long existCount = baseMapper.selectCount(Wrappers.lambdaQuery() + .ne(TbShopTableBooking::getId, entity.getId()) + .eq(TbShopTableBooking::getShopId, dto.getShopId()) + .eq(TbShopTableBooking::getShopTableId, dto.getShopTableId()) + .eq(TbShopTableBooking::getBookingDate, dto.getBookingDate()) + .eq(TbShopTableBooking::getBookingType, dto.getBookingType()) + .ne(TbShopTableBooking::getStatus, -1) + .eq(TbShopTableBooking::getDelFlag, 0) + ); + if (existCount > 0) { + throw new BadRequestException(StrUtil.format("该台桌{}档在{}已被预订", BOOKING_TYPE.get(entity.getBookingType()), DateUtil.formatDate(entity.getBookingDate()))); + } + BeanUtil.copyProperties(dto, entity, CopyOptions.create().setIgnoreNullValue(true).setIgnoreProperties("orderNo", "status", "createTime", "createUserName", "delFlag")); + entity.setUpdateTime(new Date()); + return super.updateById(entity); + } + + @Override + public void markStatus(Long id, Integer status) { + if (id == null) { + throw new BadRequestException("id不能为空"); + } + if (status == null) { + throw new BadRequestException("状态不能为空"); + } + TbShopTableBooking entity = super.getById(id); + if (entity == null) { + throw new BadRequestException("预订信息不存在"); + } + entity.setStatus(status); + entity.setUpdateTime(new Date()); + if (status == 10) { + entity.setArrivedTime(new Date()); + } else { + entity.setArrivedTime(null); + } + super.updateById(entity); + } + + @Override + public void delete(Long id) { + baseMapper.update(Wrappers.lambdaUpdate() + .set(TbShopTableBooking::getDelFlag, 1) + .eq(TbShopTableBooking::getId, id)); + } + + @Override + public String getBookingSms(Integer shopId) { + if (shopId == null) { + throw new BadRequestException("shopId不能为空"); + } + TbShopInfo shop = tbShopInfoRepository.getById(shopId); + if (shop == null) { + throw new BadRequestException("店铺信息不存在"); + } + return shop.getBookingSms(); + } + + @Override + public List findShopAreaList(Integer shopId) { + List tableList = mpShopTableMapper.selectList(Wrappers.lambdaQuery().eq(TbShopTable::getShopId, shopId).eq(TbShopTable::getIsPredate, 1)); + if (CollUtil.isEmpty(tableList)) { + return new ArrayList<>(); + } + Set areaId = tableList.stream().map(TbShopTable::getAreaId).collect(Collectors.toSet()); + List areaList = mpShopAreaMapper.selectList(Wrappers.lambdaQuery().in(TbShopArea::getId, areaId)); + if (CollUtil.isEmpty(areaList)) { + return new ArrayList<>(); + } + return areaList; + } + + @Override + public List findShopTableList(Map params) { + MapProxy mapProxy = MapProxy.create(params); + Integer areaId = mapProxy.getInt("areaId"); + TbShopTableBooking param = BeanUtil.toBean(params, TbShopTableBooking.class); + List tableList = mpShopTableMapper.selectList( + Wrappers.lambdaQuery() + .eq(TbShopTable::getShopId, param.getShopId()) + .eq(TbShopTable::getIsPredate, 1) + .eq(areaId != null, TbShopTable::getAreaId, areaId) + .orderByAsc(TbShopTable::getName) + ); + if (CollUtil.isEmpty(tableList)) { + return new ArrayList<>(); + } + List result = BeanUtil.copyToList(tableList, ShopTableBookingDTO.class); + Date bookingDate = param.getBookingDate(); + String bookingType = param.getBookingType(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(bookingDate != null, TbShopTableBooking::getBookingDate, bookingDate); + wrapper.eq(StrUtil.isNotEmpty(bookingType), TbShopTableBooking::getBookingType, bookingType); + wrapper.ne(TbShopTableBooking::getStatus, -1); + wrapper.eq(TbShopTableBooking::getDelFlag, 0); + List list = super.list(wrapper); + if (CollUtil.isEmpty(list)) { + return result; + } + for (ShopTableBookingDTO dto : result) { + dto.setBookingInfo(list.stream().filter(item -> item.getShopTableId().equals(dto.getId()) && item.getStatus() != -1).findFirst().orElse(null)); + } + return result; + } + + @Override + public Map summary(Integer shopId, String[] phoneNos) { + List phoneNoList = Arrays.asList(phoneNos).stream().distinct().collect(Collectors.toList()); + List> splits = CollUtil.split(phoneNoList, 10); + List> list = new ArrayList<>(); + for (List split : splits) { + List> subList = baseMapper.summaryByPhoneNos(shopId, split); + list.addAll(subList); + } + Map result = new HashMap<>(phoneNoList.size()); + for (String phoneNo : phoneNos) { + Map fillData = new HashMap<>(3); + fillData.put("consumeOrders", 0); + fillData.put("cancelOrders", 0); + fillData.put("phoneNumber", phoneNo); + Map data = list.stream().filter(item -> phoneNo.equals(item.get("phoneNumber"))).findFirst().orElse(fillData); + result.put(phoneNo, data); + } + return result; + } + + @Override + public void batchTimeout() { + baseMapper.update(Wrappers.lambdaUpdate() + .set(TbShopTableBooking::getStatus, 999) + .set(TbShopTableBooking::getUpdateTime, new Date()) + .eq(TbShopTableBooking::getStatus, 20) + .last("and TIMESTAMPDIFF(MINUTE, NOW(), booking_time) >= timeout_minute")); + } + + @Override + public void autoCancel() { + // 15分钟后自动取消 + baseMapper.update(Wrappers.lambdaUpdate() + .set(TbShopTableBooking::getStatus, -1) + .set(TbShopTableBooking::getUpdateTime, new Date()) + .eq(TbShopTableBooking::getStatus, 999) + .last("and TIMESTAMPDIFF(MINUTE, NOW(), booking_time) >= timeout_minute+15")); + } + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbThirdPartyCouponRecordServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbThirdPartyCouponRecordServiceImpl.java new file mode 100644 index 00000000..2c8b293b --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbThirdPartyCouponRecordServiceImpl.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord; +import cn.ysk.cashier.mybatis.service.TbThirdPartyCouponRecordService; +import cn.ysk.cashier.mybatis.mapper.TbThirdPartyCouponRecordMapper; +import org.springframework.stereotype.Service; + +/** +* @author Administrator +* @description 针对表【tb_third_party_coupon_record】的数据库操作Service实现 +* @createDate 2024-11-25 17:57:03 +*/ +@Service +public class TbThirdPartyCouponRecordServiceImpl extends ServiceImpl + implements TbThirdPartyCouponRecordService{ + +} + + + + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index eff0d41e..a761734b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -15,16 +15,16 @@ */ package cn.ysk.cashier.pojo.order; -import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord; -import lombok.Data; import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.util.NumberUtil; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import javax.persistence.*; -import javax.validation.constraints.*; -import java.math.BigDecimal; +import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.math.BigDecimal; import java.math.RoundingMode; /** @@ -177,6 +177,14 @@ public class TbCashierCart implements Serializable { private String discountSaleNote; private Boolean isPrint; private String useCouponInfo; + // 是否团购券商品 + private Integer isThirdCoupon; + // 是否等叫 + private Integer isWaitCall; + // 套餐商品,选择的商品信息 + private String proGroupInfo; + // 商品类型 + private String typeEnum; public void copy(TbCashierCart source) { BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); @@ -186,17 +194,24 @@ public class TbCashierCart implements Serializable { * 根据是否会员充值价格 */ public void resetTotalAmount() { + if (isThirdCoupon != null && isThirdCoupon == 1) { + totalAmount = BigDecimal.ZERO; + return; + } if ("false".equals(isPack)) { packFee = BigDecimal.ZERO; } if ("true".equals(isGift)) { totalAmount = packFee; } else { + discountSaleAmount = discountSaleAmount == null ? BigDecimal.ZERO : discountSaleAmount; + BigDecimal subtract; if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { - totalAmount = totalNumber.multiply(memberPrice).add(packFee); + subtract = memberPrice.subtract(discountSaleAmount); } else { - totalAmount = totalNumber.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice).add(packFee); + subtract = salePrice.subtract(discountSaleAmount); } + totalAmount = totalNumber.multiply(subtract.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : subtract).add(packFee); } } @@ -204,6 +219,10 @@ public class TbCashierCart implements Serializable { * 根据是否会员充值价格 */ public void resetTotalAmount(BigDecimal discountRadio) { + if (isThirdCoupon != null && isThirdCoupon == 1) { + totalAmount = BigDecimal.ZERO; + return; + } if (discountRadio == null) { discountRadio = BigDecimal.ONE; } @@ -213,10 +232,14 @@ public class TbCashierCart implements Serializable { if ("true".equals(isGift)) { totalAmount = packFee; } else { + discountSaleAmount = discountSaleAmount == null ? BigDecimal.ZERO : discountSaleAmount; + BigDecimal subtract; if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { - totalAmount = totalNumber.multiply(memberPrice).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP); + subtract = memberPrice.subtract(discountSaleAmount); + totalAmount = totalNumber.multiply(subtract).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP); } else { - totalAmount = totalNumber.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice) + subtract = salePrice.subtract(discountSaleAmount); + totalAmount = totalNumber.multiply(subtract) .add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP); } } @@ -227,6 +250,9 @@ public class TbCashierCart implements Serializable { * */ public BigDecimal getTotalAmountByNum(BigDecimal num, BigDecimal discountRadio) { + if (isThirdCoupon != null && isThirdCoupon == 1) { + return BigDecimal.ZERO; + } if (discountRadio == null) { discountRadio = new BigDecimal("1"); } @@ -235,7 +261,7 @@ public class TbCashierCart implements Serializable { } if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { - return num.multiply(memberPrice).multiply(discountRadio).add(packFee).setScale(2, RoundingMode.HALF_UP); + return num.multiply(memberPrice.subtract(NumberUtil.null2Zero(discountSaleAmount))).multiply(discountRadio).add(packFee).setScale(2, RoundingMode.HALF_UP); }else { return num.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP); } @@ -247,4 +273,5 @@ public class TbCashierCart implements Serializable { } + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java index 0809f1c3..893a5049 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java @@ -15,6 +15,7 @@ */ package cn.ysk.cashier.pojo.order; +import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord; import com.baomidou.mybatisplus.annotation.TableField; import lombok.Data; import cn.hutool.core.bean.BeanUtil; @@ -132,10 +133,15 @@ public class TbOrderDetail implements Serializable { private Integer userCouponId; private Integer isMember; private Integer isTemporary; + private String discountSaleNote; + private BigDecimal discountSaleAmount; private Boolean isPrint; private String useCouponInfo; private BigDecimal returnAmount; private BigDecimal canReturnAmount; + private Integer isThirdCoupon; + private Integer isWaitCall; + private String proGroupInfo; public void copy(TbOrderDetail source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderInfo.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderInfo.java index 260e82cd..5b81e87c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderInfo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderInfo.java @@ -252,8 +252,11 @@ public class TbOrderInfo implements Serializable { // 满减抵扣金额 private BigDecimal fullCouponDiscountAmount; private Integer isPostpaid; + private Integer isWaitCall; + private String creditBuyerId; public void copy(TbOrderInfo source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java index 9a7adb1e..3620eb27 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java @@ -17,6 +17,7 @@ package cn.ysk.cashier.pojo.product; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; +import cn.ysk.cashier.vo.ProductGroupVo; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -50,14 +51,6 @@ public class TbProduct implements Serializable { @TableId(type = IdType.AUTO) private Integer id; - @Column(name = "`source_path`") - @ApiModelProperty(value = "商品来源 NORMAL普通商品 --,SCORE积分商品") - private String sourcePath="NORMAL"; - - @Column(name = "`merchant_id`") - @ApiModelProperty(value = "商户Id") - private String merchantId = "PLANT_ID"; - @Column(name = "`shop_id`") @ApiModelProperty(value = "店铺id") private String shopId; @@ -66,10 +59,6 @@ public class TbProduct implements Serializable { @ApiModelProperty(value = "商品名称") private String name; - @Column(name = "`type`") - @ApiModelProperty(value = "商品类型(属性):REAL- 实物商品 VIR---虚拟商品") - private String type = "REAL"; - @Column(name = "`pack_fee`") @ApiModelProperty(value = "包装费") private BigDecimal packFee; @@ -83,6 +72,10 @@ public class TbProduct implements Serializable { @ApiModelProperty(value = "单位Id") private Integer unitId; + @Transient + @TableField(exist = false) + private String unitName; + @Column(name = "`cover_img`") @ApiModelProperty(value = "商品封面图") private String coverImg; @@ -95,84 +88,35 @@ public class TbProduct implements Serializable { @ApiModelProperty(value = "商品规格") private Integer specId; - @Column(name = "`brand_id`") - @ApiModelProperty(value = "品牌Id") - private Integer brandId; - @Column(name = "`short_title`") @ApiModelProperty(value = "短标题--促销语") private String shortTitle; - @Column(name = "`low_member_price`") - @ApiModelProperty(value = "lowMemberPrice") - private BigDecimal lowMemberPrice; - - @Column(name = "`unit_snap`") - @ApiModelProperty(value = "单位镜像") - private String unitSnap; - - @Column(name = "`share_img`") - @ApiModelProperty(value = "商品分享图") - private String shareImg; - @Column(name = "`images`") @ApiModelProperty(value = "商品图片(第一张为缩略图,其他为详情)") private String images; - @Column(name = "`video`") - @ApiModelProperty(value = "商品视频URL地址") - private String video; - - @Column(name = "`video_cover_img`") - @ApiModelProperty(value = "视频封面图") - private String videoCoverImg; - @Column(name = "`sort`") @ApiModelProperty(value = "排序") private Integer sort = 0; - @Column(name = "`limit_number`") - @ApiModelProperty(value = "0-不限购") - private Integer limitNumber = 0; - - @Column(name = "`product_score`") - @ApiModelProperty(value = "商品赚送积分") - private Integer productScore; - @Column(name = "`status`",nullable = false) @NotNull @ApiModelProperty(value = "0--待审核 1审核通过 -1审核失败 -2违规下架") private Integer status = 0; - @Column(name = "`fail_msg`") - @ApiModelProperty(value = "审核失败原因") - private String failMsg; - - @Column(name = "`is_recommend`") - @ApiModelProperty(value = "是否推荐,店铺推荐展示") - private Integer isRecommend = 0; - @Column(name = "`is_hot`") @ApiModelProperty(value = "是否热销") private Integer isHot = 0; - @Column(name = "`is_new`") - @ApiModelProperty(value = "是否新品") - private Integer isNew; - - @Column(name = "`is_on_sale`") - @ApiModelProperty(value = "是否促销1-是0-否") - private Integer isOnSale = 0; - - @Column(name = "`is_show`") - @ApiModelProperty(value = "是否展示0-下架 1上架---废弃") - private Integer isShow = 0; + @Column(name = "`type`") + @ApiModelProperty(value = "商品类型(属性):普通商品 normal 套餐商品 package 称重商品 weigh 团购券 coupon") + private String type; @Column(name = "`type_enum`") - @ApiModelProperty(value = "商品规格:0-单规格 1多规格") + @ApiModelProperty(value = "商品规格:normal-单规格 sku-多规格") private String typeEnum; - @Column(name = "`is_del`",nullable = false) @NotNull @ApiModelProperty(value = "是否回收站 0-否,1回收站") @@ -186,120 +130,22 @@ public class TbProduct implements Serializable { @ApiModelProperty(value = "是否暂停销售") private Integer isPauseSale = 0; - @Column(name = "`is_free_freight`",nullable = false) - @NotNull - @ApiModelProperty(value = "是否免邮1-是 0-否") - private Integer isFreeFreight=1; - - @Column(name = "`freight_id`") - @ApiModelProperty(value = "邮费模版") - private Long freightId; - - @Column(name = "`strategy_type`") - @ApiModelProperty(value = "商品当前生效策略") - private String strategyType; - - @Column(name = "`strategy_id`") - @ApiModelProperty(value = "策略Id") - private Integer strategyId = 1; - - @Column(name = "`is_vip`") - @ApiModelProperty(value = "vip专属") - private Integer isVip = 0; - - @Column(name = "`is_delete`",nullable = false) - @NotNull - @ApiModelProperty(value = "是否删除") - private Integer isDelete = 0; - - @Column(name = "`notice`") - @ApiModelProperty(value = "购买须知") - private String notice; - @Column(name = "`created_at`") - @ApiModelProperty(value = "createdAt") + @ApiModelProperty(value = "创建时间") private Long createdAt; @Column(name = "`updated_at`") - @ApiModelProperty(value = "updatedAt") + @ApiModelProperty(value = "更新时间") private Long updatedAt; - @Column(name = "`base_sales_number`") - @ApiModelProperty(value = "基础出售数量") - private Double baseSalesNumber =0.00; - - @Column(name = "`real_sales_number`") - @ApiModelProperty(value = "实际销量") - private Integer realSalesNumber = 0; - - @Column(name = "`sales_number`") - @ApiModelProperty(value = "合计销量") - private Integer salesNumber = 0; - - @Column(name = "`thumb_count`") - @ApiModelProperty(value = "点赞次数") - private Integer thumbCount = 0; - - @Column(name = "`store_count`") - @ApiModelProperty(value = "收藏次数") - private Integer storeCount = 0; - - @Column(name = "`furnish_meal`") - @ApiModelProperty(value = "支持堂食") - private Integer furnishMeal = 0; - - @Column(name = "`furnish_express`") - @ApiModelProperty(value = "支持配送") - private Integer furnishExpress = 0; - - @Column(name = "`furnish_draw`") - @ApiModelProperty(value = "支持自提") - private Integer furnishDraw = 0; - - @Column(name = "`furnish_vir`") - @ApiModelProperty(value = "支持虚拟") - private Integer furnishVir = 0; - - @Column(name = "`is_combo`") - @ApiModelProperty(value = "是否套餐") - private Integer isCombo =0; + @Column(name = "`group_type`") + @ApiModelProperty(value = "套餐类型 0固定套餐 1可选套餐") + private Integer groupType; @Column(name = "`group_snap`") @ApiModelProperty(value = "套餐内容") private String groupSnap; - @Column(name = "`is_show_cash`") - @ApiModelProperty(value = "isShowCash") - private Integer isShowCash =0; - - @Column(name = "`is_show_mall`") - @ApiModelProperty(value = "isShowMall") - private Integer isShowMall = 0; - - @Column(name = "`is_need_examine`") - @ApiModelProperty(value = "是否需要审核") - private Integer isNeedExamine = 0; - - @Column(name = "`show_on_mall_status`") - @ApiModelProperty(value = "线上商城展示状态0待审核 -1 异常 1正常") - private Integer showOnMallStatus = 1; - - @Column(name = "`show_on_mall_time`") - @ApiModelProperty(value = "提交审核时间") - private Long showOnMallTime; - - @Column(name = "`show_on_mall_error_msg`") - @ApiModelProperty(value = "线上商城展示失败原因") - private String showOnMallErrorMsg; - - @Column(name = "`enable_label`") - @ApiModelProperty(value = "使用标签打印 选择 是 并在 前台>本机设置 勾选打印标签后,收银完成后会自动打印对应数量的标签数") - private Integer enableLabel = 0; - - @Column(name = "`tax_config_id`") - @ApiModelProperty(value = "税率") - private String taxConfigId; - @Column(name = "spec_info") @ApiModelProperty(value = "specInfo") private String specInfo; @@ -332,6 +178,42 @@ public class TbProduct implements Serializable { @ApiModelProperty("库存警戒线") private Integer warnLine = 0; + @Column(name = "show_type") + @ApiModelProperty("堂食 table 自取 dine 配送 delivery 快递 express") + private String showType; + + @Column(name = "weight") + @ApiModelProperty("称重 价格/千克") + private BigDecimal weight; + + @Column(name = "is_temp_price") + @ApiModelProperty("是否允许临时改价") + private Integer isTempPrice = 0; + + @Column(name = "day_limit") + @ApiModelProperty("日销售上限") + private Integer dayLimit = 0; + + @Column(name = "single_order_limit") + @ApiModelProperty("每单销售上限") + private Integer singleOrderLimit = 0; + + @Column(name = "single_people_limit") + @ApiModelProperty("每人销售上限") + private Integer singlePeopleLimit = 0; + + @Column(name = "days") + @ApiModelProperty("周数组 周一,周二,周日") + private String days; + + @Column(name = "start_time") + @ApiModelProperty("可用开始时间") + private String startTime; + + @Column(name = "end_time") + @ApiModelProperty("可用结束时间") + private String endTime; + @Transient @TableField(exist = false) private TbProductSkuResult skuResult; @@ -339,7 +221,9 @@ public class TbProduct implements Serializable { @Transient @TableField(exist = false) private List> specList; - + @Transient + @TableField(exist = false) + private List proGroupVo; public void copy(TbProduct source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java index 83b4a4b5..c7e8482a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java @@ -131,6 +131,22 @@ public class TbMerchantAccount implements Serializable { @ApiModelProperty(value = "操作密码") private String pwd; + @Column(name = "`bind_account`") + @ApiModelProperty(value = "开票系统账号") + private String bindAccount; + + @Column(name = "`article`") + @ApiModelProperty(value = "项目分类") + private String article; + + @Column(name = "`sd_type`") + @ApiModelProperty(value = "数电发票类型") + private String sdType; + + @Column(name = "`tax_amount`") + @ApiModelProperty(value = "税率") + private String taxAmount; + public void copy(TbMerchantAccount source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java index 5720d7bd..fcabc2ae 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java @@ -15,14 +15,14 @@ */ package cn.ysk.cashier.pojo.shop; -import lombok.Data; import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.copier.CopyOptions; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + import javax.persistence.*; -import javax.validation.constraints.*; -import java.math.BigDecimal; import java.io.Serializable; +import java.math.BigDecimal; /** * @website https://eladmin.vip @@ -41,6 +41,10 @@ public class TbShopInfo implements Serializable { @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; + @Column(name = "`main_id`") + @ApiModelProperty(value = "总店铺帐号") + private String mainId; + @Column(name = "`account`") @ApiModelProperty(value = "店铺帐号") private String account; @@ -138,9 +142,13 @@ public class TbShopInfo implements Serializable { private String city; @Column(name = "`type`") - @ApiModelProperty(value = "店铺类型 超市--MARKET---其它店SHOP") + @ApiModelProperty(value = "店铺类型 单店--only 连锁店--chain--加盟店join") private String type; + @Column(name = "`tube_type`") + @ApiModelProperty(value = "管理 0否 1是") + private Integer tubeType; + @Column(name = "`industry`") @ApiModelProperty(value = "行业") private String industry; @@ -171,7 +179,7 @@ public class TbShopInfo implements Serializable { @Column(name = "`on_sale`") @ApiModelProperty(value = "0停业1,正常营业,网上售卖") - private Integer onSale; + private Integer onSale = 1; @Column(name = "`settle_type`") @ApiModelProperty(value = "0今日,1次日") @@ -244,33 +252,33 @@ public class TbShopInfo implements Serializable { @Column(name = "is_custom") @ApiModelProperty(value = "是否允许用户自定义金额") - private String isCustom; + private String isCustom = "0"; @Column(name = "is_return") - @ApiModelProperty(value = "是否允许用户自定义金额") - private String isReturn; + @ApiModelProperty(value = "是否开启退款密码 ") + private String isReturn = "0"; @Column(name = "is_member_in") - @ApiModelProperty(value = "是否允许用户自定义金额") - private String isMemberIn; + @ApiModelProperty(value = "是否开启会员充值密码 ") + private String isMemberIn = "0"; @Column(name = "is_member_return") - @ApiModelProperty(value = "是否允许用户自定义金额") - private String isMemberReturn; + @ApiModelProperty(value = "是否开启会员退款密码 ") + private String isMemberReturn = "0"; @Column(name = "is_member_price") @ApiModelProperty(value = "是否启用会员价 0否1是") - private Integer isMemberPrice; + private Integer isMemberPrice = 0; @Column(name = "consume_colony") @ApiModelProperty(value = "积分群体 all-所有 vip-仅针对会员") - private String consumeColony; + private String consumeColony = "all"; @Column(name = "is_table_fee") @ApiModelProperty(value = "是否免除桌位费 0否1是") - private Integer isTableFee; + private Integer isTableFee = 1; @Column(name = "table_fee") @ApiModelProperty(value = "桌位费") @@ -287,6 +295,10 @@ public class TbShopInfo implements Serializable { @ApiModelProperty(value = "店铺收款码") private String paymentQrcode; + @Column(name = "booking_sms") + @ApiModelProperty(value = "台桌预订短信") + private String bookingSms; + public void copy(TbShopInfo source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopPurveyorTransact.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopPurveyorTransact.java index 93095600..cdfce3c8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopPurveyorTransact.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopPurveyorTransact.java @@ -1,20 +1,7 @@ -/* -* 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.pojo.shop; +import cn.ysk.cashier.cons.domain.SuppFlow; +import cn.ysk.cashier.cons.domain.TbConsInfo; import lombok.Data; import cn.hutool.core.bean.BeanUtil; import io.swagger.annotations.ApiModelProperty; @@ -23,6 +10,7 @@ import javax.persistence.*; import javax.validation.constraints.*; import java.math.BigDecimal; import java.io.Serializable; +import java.util.List; /** * @website https://eladmin.vip @@ -94,7 +82,14 @@ public class TbShopPurveyorTransact implements Serializable { @ApiModelProperty(value = "type") private String type; + @Column(name = "`con_infos`") + private String conInfos; + @Transient + private List conFlows; + + @Transient + private List cons; public void copy(TbShopPurveyorTransact source){ diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java b/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java index 1e36b4d9..09172c35 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java @@ -2,6 +2,7 @@ package cn.ysk.cashier.quartz.task; import cn.ysk.cashier.dto.product.StockCountDTO; import cn.ysk.cashier.mybatis.service.TbPointsExchangeRecordService; +import cn.ysk.cashier.mybatis.service.TbShopTableBookingService; import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.pojo.product.TbProductStockDetail; import cn.ysk.cashier.repository.order.StockCountRepository; @@ -46,6 +47,8 @@ public class TestTask { private EntityManager entityManager; @Autowired private TbPointsExchangeRecordService tbPointsExchangeRecordService; + @Autowired + private TbShopTableBookingService tbShopTableBookingService; private final TbCashierCartService tbCashierCartService; private final TbOrderInfoService orderInfoService; @@ -103,6 +106,10 @@ public class TestTask { public void cancelPointsExchangeOrder(){ log.info("积分商品订单取消定时任务执行"); tbPointsExchangeRecordService.authCancel(); + log.info("预定订单超时定时任务执行"); + tbShopTableBookingService.batchTimeout(); + log.info("预定订单取消定时任务执行"); + tbShopTableBookingService.autoCancel(); } @Transactional(rollbackFor = Exception.class) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductGroupRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductGroupRepository.java index 063d4e3e..e04741e4 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductGroupRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductGroupRepository.java @@ -2,6 +2,7 @@ package cn.ysk.cashier.repository.product; import cn.ysk.cashier.pojo.product.TbProductGroup; 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; import org.springframework.data.repository.query.Param; @@ -23,4 +24,13 @@ public interface TbProductGroupRepository extends JpaRepository findByIds(List productIds); + + @Query("SELECT groups from TbProductGroup groups where groups.shopId = :shopId") + List searchGroupByShopId(@Param("shopId") Integer shopId); + + @Modifying + @Query("delete from TbProductGroup groups where groups.shopId = :shopId") + void clearShopGroup(@Param("shopId") Integer shopId); + + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java index 0d2fbb15..e5cdad6b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java @@ -14,23 +14,34 @@ import java.math.BigDecimal; import java.util.List; /** -* @website https://eladmin.vip -* @author lyf -* @date 2023-12-11 -**/ + * @author lyf + * @website https://eladmin.vip + * @date 2023-12-11 + **/ public interface TbProductRepository extends JpaRepository, JpaSpecificationExecutor { @Query("SELECT product from TbProduct product where product.id in :productIds order by product.sort") List findByIds(List productIds); - @Query(value = "update tb_product set status = -1 where id in :productIds",nativeQuery = true) + @Query("SELECT product from TbProduct product where product.shopId = :shopId and product.status=1 and product.isDel=0 and product.type in ('coupon','package') ") + List findPackageByShopId(@Param("shopId") String shopId); + + + @Query("SELECT product from TbProduct product where product.shopId = :shopId and product.status=1 and product.isDel=0") + List findByShopId(@Param("shopId") String shopId); + + @Modifying + @Query("delete FROM TbProduct product where product.shopId = :shopId") + void clearShopPro(@Param("shopId") String shopId); + + @Query(value = "update tb_product set status = -1 and is_del = 1 where id in :productIds", nativeQuery = true) @Modifying void updateByStatus(List productIds); @Modifying @Query("update FROM TbProduct pro set pro.stockNumber=:stockNumber WHERE pro.id =:productId") - void updateProductStockNumber(@Param("productId") Integer productId,@Param("stockNumber") Integer stockNumber); + void updateProductStockNumber(@Param("productId") Integer productId, @Param("stockNumber") Integer stockNumber); @Modifying @Query("update FROM TbProduct pro set pro.stockNumber=pro.stockNumber+:number WHERE pro.id =:productId") @@ -39,8 +50,8 @@ public interface TbProductRepository extends JpaRepository, @Transactional @Modifying @Query("update FROM TbProduct pro set pro.stockNumber=:stocktakinNum where pro.id=:id and pro.stockNumber=:stockNumber") - Integer updateStock(@Param("id") Integer id,@Param("stockNumber") Integer stockNumber, - @Param("stocktakinNum") Integer stocktakinNum); + Integer updateStock(@Param("id") Integer id, @Param("stockNumber") Integer stockNumber, + @Param("stocktakinNum") Integer stocktakinNum); @Modifying @Query("update TbProduct set stockNumber=stockNumber+:num where id=:id") @@ -64,6 +75,6 @@ public interface TbProductRepository extends JpaRepository, @Transactional @Modifying @Query("UPDATE TbProduct p SET p.warnLine = :warnLine WHERE p.shopId = :shopId") - Integer updateWarnLineByShopId(@Param("warnLine")Integer warnLine, @Param("shopId")String shopId); + Integer updateWarnLineByShopId(@Param("warnLine") Integer warnLine, @Param("shopId") String shopId); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java index ba6dcd1f..598b5a01 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java @@ -22,6 +22,12 @@ public interface TbProductSkuRepository extends JpaRepository searchSku(@Param("productId")String productId); + @Query("SELECT sku FROM TbProductSku sku WHERE sku.shopId = :shopId and sku.isDel=0") + List searchSkuByShopId(@Param("shopId")String shopId); + + @Modifying + @Query("delete FROM TbProductSku sku WHERE sku.shopId = :shopId ") + void clearShopSku(@Param("shopId")String shopId); @Transactional @Modifying @@ -50,4 +56,16 @@ public interface TbProductSkuRepository extends JpaRepository searchProRealSalesNumber(@Param("ids") List ids); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuResultRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuResultRepository.java index 0f818a00..a78d774a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuResultRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuResultRepository.java @@ -1,18 +1,3 @@ -/* -* 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.repository.product; import cn.ysk.cashier.pojo.product.TbProductSkuResult; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSpecRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSpecRepository.java index b801a505..7be7e20b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSpecRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSpecRepository.java @@ -1,41 +1,50 @@ /* -* 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. -*/ + * 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.repository.product; import cn.ysk.cashier.pojo.product.TbProductSpec; 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; import org.springframework.data.repository.query.Param; import java.util.List; /** -* @website https://eladmin.vip -* @author lyf -* @date 2024-01-03 -**/ + * @author lyf + * @website https://eladmin.vip + * @date 2024-01-03 + **/ public interface TbProductSpecRepository extends JpaRepository, JpaSpecificationExecutor { @Query("SELECT spec FROM TbProductSpec spec WHERE spec.id IN :ids") - List searchSpec(@Param("ids")List ids); + List searchSpec(@Param("ids") List ids); @Query("SELECT spec FROM TbProductSpec spec WHERE spec.id = :ids") - TbProductSpec searchSpec(@Param("ids")Integer ids); + TbProductSpec searchSpec(@Param("ids") Integer ids); @Query("SELECT spec FROM TbProductSpec spec WHERE spec.shopId = :shopId and spec.name = :name") - TbProductSpec findAllByName(@Param("shopId")String shopId, @Param("name")String name); + TbProductSpec findAllByName(@Param("shopId") String shopId, @Param("name") String name); + + + @Query("SELECT spec FROM TbProductSpec spec WHERE spec.shopId = :shopId") + List searchSpecByShopId(@Param("shopId") String shopId); + + @Modifying + @Query("delete FROM TbProductSpec spec WHERE spec.shopId = :shopId") + void clearShopSpec(@Param("shopId") String shopId); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbShopCategoryRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbShopCategoryRepository.java index 5e29938e..a74e1e88 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbShopCategoryRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbShopCategoryRepository.java @@ -20,6 +20,7 @@ import org.apache.ibatis.annotations.Param; import org.springframework.data.domain.Page; 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; import org.springframework.data.domain.Pageable; @@ -44,4 +45,10 @@ public interface TbShopCategoryRepository extends JpaRepository searchCategory(@Param("ids")List ids); + @Query("SELECT category FROM TbShopCategory category where category.shopId = :shopId and (category.pid is null or category.pid = '')") + List searchCategoryByShopId(@Param("shopId") String shopId); + + @Modifying + @Query("delete FROM TbShopCategory category where category.shopId = :shopId") + void clearShopCategory(@Param("shopId") String shopId); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUnitRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUnitRepository.java index 06ff650c..2e791e25 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUnitRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUnitRepository.java @@ -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.repository.shop; import cn.ysk.cashier.pojo.shop.TbShopUnit; 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; import org.springframework.data.repository.query.Param; @@ -37,4 +23,11 @@ public interface TbShopUnitRepository extends JpaRepository @Query("SELECT unit from TbShopUnit unit where unit.name = :name and unit.shopId = :shopId") TbShopUnit findName(@Param("name")String name,@Param("shopId")String shopId); + + @Query("SELECT unit FROM TbShopUnit unit WHERE unit.shopId = :shopId") + List searchUnitByShopId(@Param("shopId")String shopId); + + @Modifying + @Query("delete FROM TbShopUnit unit WHERE unit.shopId = :shopId") + void clearShopUnit(@Param("shopId")String shopId); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUserDutyDetailRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUserDutyDetailRepository.java index c4db86fa..160b739a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUserDutyDetailRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUserDutyDetailRepository.java @@ -1,12 +1,7 @@ package cn.ysk.cashier.repository.shop; -import javax.persistence.Tuple; import cn.ysk.cashier.pojo.TbShopUserDutyDetail; -import org.apache.ibatis.annotations.Param; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; - -import java.util.List; /** * @author lyf @@ -14,14 +9,4 @@ import java.util.List; public interface TbShopUserDutyDetailRepository extends JpaRepository { - @Query(value = "SELECT " + - "sum( num ), " + - "product_id " + - "FROM " + - "tb_shop_user_duty_detail " + - "WHERE " + - "product_id IN :ids " + - "GROUP BY " + - "product_id",nativeQuery = true) - List searchUUserDutyDetail(@Param("ids") List ids); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/resp/PhpCommonResp.java b/eladmin-system/src/main/java/cn/ysk/cashier/resp/PhpCommonResp.java new file mode 100644 index 00000000..afe66147 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/resp/PhpCommonResp.java @@ -0,0 +1,11 @@ +package cn.ysk.cashier.resp; + +import lombok.Data; + +@Data +public class PhpCommonResp { + private String code; + private String msg; + private long time; + private T data; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/BindService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/BindService.java new file mode 100644 index 00000000..e77e7493 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/BindService.java @@ -0,0 +1,42 @@ +package cn.ysk.cashier.service; + +import cn.ysk.cashier.dto.BindingDto; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import java.util.Map; + +/** + * 开票服务员 + */ +public interface BindService { + + /** + * 绑定 + */ + JSONObject binding(Map params); + + /** + * 商家提交开票信息 + */ + JSONObject subInvoicing(Map params); + + /** + * 项目分类 + */ + JSONObject industry(BindingDto bindingDto); + + + /** + * 计算税额 + */ + JSONObject storeSe(Map params); + + /** + * 数电发票类型 + */ + JSONArray digitalInvoice(); + + + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java new file mode 100644 index 00000000..14af68f4 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/ThirdPartyCouponService.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.service; + +import cn.ysk.cashier.dto.thirdcoupon.CheckCouponDTO; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +public interface ThirdPartyCouponService { + + String getBindUrl(Integer shopId); + + String getUnBindUrl(Integer shopId); + + Map getActivateCoupon(Integer shopId, String code); + + Map checkCoupon(CheckCouponDTO checkCouponDTO); + + Map revokeCoupon(CheckCouponDTO checkCouponDTO); + + Map getState(Integer shopId); +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BindServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BindServiceImpl.java new file mode 100644 index 00000000..c6978cbd --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BindServiceImpl.java @@ -0,0 +1,121 @@ +package cn.ysk.cashier.service.impl; + +import cn.hutool.http.HttpUtil; +import cn.ysk.cashier.dto.BindingDto; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.pojo.shop.TbMerchantAccount; +import cn.ysk.cashier.pojo.shop.TbShopInfo; +import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository; +import cn.ysk.cashier.repository.shop.TbShopInfoRepository; +import cn.ysk.cashier.service.BindService; +import cn.ysk.cashier.utils.CacheKey; +import cn.ysk.cashier.utils.RedisUtils; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +@Service +public class BindServiceImpl implements BindService { + + @Autowired + private TbMerchantAccountRepository accountRepository; + @Autowired + private TbShopInfoRepository tbShopInfoRepository; + @Lazy + @Autowired + private RedisUtils redisUtils; + private final String url = "http://test.invoice.sxczgkj.cn/api/"; + + @Override + public JSONObject binding(Map params) { + String result = HttpUtil.post(url + "cash/binding", params, 5000); + JSONObject jsonObject = JSONObject.parseObject(result); + if (jsonObject.getInteger("code").equals(1)) { + return jsonObject.getJSONObject("data"); + } else { + throw new BadRequestException(jsonObject.getString("msg")); + } + } + + @Override + public JSONObject subInvoicing(Map params) { + String shopId = params.get("shopId").toString(); + params.remove("shopId"); + String result = HttpUtil.post(url + "cash/subinvoicing", params, 5000); + JSONObject jsonObject = JSONObject.parseObject(result); + if (jsonObject.getInteger("code").equals(1)) { +// if (StringUtils.isNotBlank(shopId)) { +// if (redisUtils.hasKey(CacheKey.INVOICE_SD_TYPE + shopId)) { +// Set articles = redisUtils.sGet(CacheKey.INVOICE_SD_TYPE + shopId); +// if (!articles.contains(params.get("article"))) { +// articles.add(params.get("article")); +// redisUtils.sSet(CacheKey.INVOICE_SD_TYPE + shopId, articles); +// } +// } +// } + return jsonObject.getJSONObject("data"); + } else { + throw new BadRequestException(jsonObject.getString("msg")); + } + } + + @Override + public JSONObject industry(BindingDto bindingDto) { +// if (StringUtils.isNotBlank(bindingDto.getArticle())) { + Map params = new HashMap<>(); + params.put("name", bindingDto.getArticle()); + params.put("page", bindingDto.getPage() == null ? 1 : bindingDto.getPage()); + String result = HttpUtil.post(url + "store/industrylistsj", params, 5000); + JSONObject jsonObject = JSONObject.parseObject(result); + if (jsonObject.getInteger("code").equals(1)) { + return jsonObject.getJSONObject("data"); + } else { + throw new BadRequestException(jsonObject.getString("msg")); + } +// } +// else { +// Set set = new HashSet<>(); +// JSONObject jsonObject = new JSONObject(); +// if (!redisUtils.hasKey(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId())) { +// TbShopInfo tbShopInfo = tbShopInfoRepository.findById(bindingDto.getShopId()).orElseGet(null); +// TbMerchantAccount account = accountRepository.findByAccount(tbShopInfo.getAccount()); +// set.add(account.getArticle()); +// redisUtils.sSet(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId(), set); +// jsonObject.put("articles", set); +// } else { +// jsonObject.put("list", redisUtils.sGet(CacheKey.INVOICE_SD_TYPE + bindingDto.getShopId())); +// } +// return jsonObject; +// } + } + + @Override + public JSONObject storeSe(Map params) { + String result = HttpUtil.post(url + "store/se", params, 5000); + JSONObject jsonObject = JSONObject.parseObject(result); + if (jsonObject.getInteger("code").equals(1)) { + return jsonObject.getJSONObject("data"); + } else { + throw new BadRequestException(jsonObject.getString("msg")); + } + } + + @Override + public JSONArray digitalInvoice() { + String result = HttpUtil.post(url + "store/digitalinvoice", "", 5000); + JSONObject jsonObject = JSONObject.parseObject(result); + if (jsonObject.getInteger("code").equals(1)) { + return jsonObject.getJSONArray("data"); + } else { + throw new BadRequestException(jsonObject.getString("msg")); + } + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java new file mode 100644 index 00000000..5160deed --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/ThirdPartyCouponServiceImpl.java @@ -0,0 +1,110 @@ +package cn.ysk.cashier.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.ysk.cashier.dto.thirdcoupon.CheckCouponDTO; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper; +import cn.ysk.cashier.pojo.shop.TbShopInfo; +import cn.ysk.cashier.resp.PhpCommonResp; +import cn.ysk.cashier.service.ThirdPartyCouponService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import java.util.HashMap; +import java.util.Map; + +@Service +public class ThirdPartyCouponServiceImpl implements ThirdPartyCouponService { + + private final MpShopInfoMapper mpShopInfoMapper; + @Value("${phpServer}") + private String phpServerUrl; + + public ThirdPartyCouponServiceImpl(RestTemplate restTemplate, MpShopInfoMapper mpShopInfoMapper) { + this.restTemplate = restTemplate; + this.mpShopInfoMapper = mpShopInfoMapper; + } + private final RestTemplate restTemplate; + + private T exec(String url, Integer shopId, Object data) { + // 获取店铺信息 + TbShopInfo shopInfo = mpShopInfoMapper.selectById(shopId); + if (shopInfo == null) { + throw new BadRequestException("店铺信息不存在"); + } + + // 设置请求头 + HttpHeaders headers = new HttpHeaders(); + headers.set("account", shopId.toString()); + + // 构造请求实体,根据 data 是否为空设置请求体 + HttpEntity entity; + if (data != null) { + Map map = BeanUtil.beanToMap(data); + map.put("title", shopInfo.getShopName()); + entity = new HttpEntity<>(map, headers); + } else { + entity = new HttpEntity<>(new HashMap(){{ + put("title", shopInfo.getShopName()); + }},headers); + } + + // 发起请求 + ResponseEntity response = restTemplate.exchange( + phpServerUrl + url, + HttpMethod.POST, // 使用 POST 请求发送 body 数据 + entity, + PhpCommonResp.class + ); + + // 处理响应 + PhpCommonResp resp = response.getBody(); + if (resp == null) { + throw new BadRequestException("请求php服务器失败"); + } + if (!"1".equals(resp.getCode())) { + throw new BadRequestException(resp.getMsg()); + } + + // 返回数据 + return (T) resp.getData(); + } + + + @Override + public String getBindUrl(Integer shopId) { + return exec("/meituan/getuisdkurl", shopId, null); + } + + @Override + public String getUnBindUrl(Integer shopId) { + return exec("/meituan/getuisdkuniurl", shopId, null); + } + + @Override + public Map getActivateCoupon(Integer shopId, String code) { + return exec("/meituan/fulfilmentcertificateprepare", shopId, new HashMap(){{ + put("code", code); + }}); + } + + @Override + public Map checkCoupon(CheckCouponDTO checkCouponDTO) { + return exec("/meituan/certificateprepare", checkCouponDTO.getShopId(), checkCouponDTO); + } + + @Override + public Map revokeCoupon(CheckCouponDTO checkCouponDTO) { + return exec("/meituan/fulfilmentcertificatecancel", checkCouponDTO.getShopId(), checkCouponDTO); + } + + @Override + public Map getState(Integer shopId) { + return exec("/meituan/searchstorestatus", shopId, null); + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java index 7761b326..b27dfb3a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java @@ -211,7 +211,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { TbOrderDetail seatInfo = null; ArrayList detailList = new ArrayList<>(); for (TbFullOrderDetail detail : details) { - if (TableConstant.CART_SEAT_ID.equals(detail.getProductId().toString())) { + if (detail.getProductId() != null && TableConstant.CART_SEAT_ID.equals(detail.getProductId().toString())) { seatInfo = detail; } else { detailList.add(detail); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index 5c37e47b..98b622a3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -2,6 +2,8 @@ package cn.ysk.cashier.service.impl.productimpl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.cons.domain.ViewConSku; import cn.ysk.cashier.cons.repository.ViewConSkuRepository; @@ -13,7 +15,6 @@ import cn.ysk.cashier.dto.product.TbProductSortCriteria; import cn.ysk.cashier.dto.shop.TbCouponCategoryDto; import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.mapper.product.TbProductMapper; -import cn.ysk.cashier.mapper.product.TbProductSkuMapper; import cn.ysk.cashier.mybatis.entity.TagProductDepts; import cn.ysk.cashier.mybatis.mapper.TbProducSkutMapper; import cn.ysk.cashier.mybatis.service.TagProductDeptsService; @@ -29,6 +30,7 @@ import cn.ysk.cashier.service.TbPlatformDictService; import cn.ysk.cashier.service.product.TbProductService; import cn.ysk.cashier.service.shop.TbCouponCategoryService; import cn.ysk.cashier.utils.*; +import cn.ysk.cashier.vo.ProductGroupVo; import cn.ysk.cashier.vo.TbProductNewVo; import cn.ysk.cashier.vo.TbProductVo; import com.alibaba.fastjson.JSONArray; @@ -38,6 +40,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.joda.time.LocalTime; import org.springframework.beans.BeanUtils; import org.springframework.data.domain.*; import org.springframework.stereotype.Service; @@ -68,7 +71,6 @@ public class TbProductServiceImpl implements TbProductService { private final TbProductSkuRepository tbProductSkuRepository; private final TbShopUnitRepository tbShopUnitRepository; private final TbProductSpecRepository tbProductSpecRepository; - private final TbProductSkuMapper TbProductSkuMapper; private final TbProductSkuResultRepository tbProductSkuResultRepository; private final TbShopCategoryRepository tbShopCategoryRepository; private final TbShopUserDutyDetailRepository tbShopUserDutyDetailRe; @@ -149,7 +151,7 @@ public class TbProductServiceImpl implements TbProductService { //销量 List objects = new ArrayList<>(); if (!productIdInt.isEmpty()) { - objects = tbShopUserDutyDetailRe.searchUUserDutyDetail(productIdInt); + objects = tbProductSkuRepository.searchProRealSalesNumber(productIdInt); } //组装 List tbProductVoList = new ArrayList<>(); @@ -179,7 +181,8 @@ public class TbProductServiceImpl implements TbProductService { skuList.add(tbProductSku); } tbProductVo.setStockNumber(stockNumber); - tbProductVo.setSkuList(skuList); +// tbProductVo.setSkuList(skuList); + tbProductVo.setSkuList(tbProductSkus); //单位 if (tbShopUnits.isEmpty()) { tbProductVo.setUnitName(""); @@ -217,9 +220,11 @@ public class TbProductServiceImpl implements TbProductService { tbProductVo.setRealSalesNumber(0.00); } else { for (Object[] o : objects) { - if (((Integer) o[1]).equals(product.getId())) { - BigDecimal bigDecimal = (BigDecimal) o[0]; - tbProductVo.setRealSalesNumber(bigDecimal.doubleValue()); + if (o[1] != null && (o[1]).equals(product.getId())) { + if (o[0] != null) { + BigDecimal bigDecimal = (BigDecimal) o[0]; + tbProductVo.setRealSalesNumber(bigDecimal.doubleValue()); + } } } } @@ -248,16 +253,16 @@ public class TbProductServiceImpl implements TbProductService { productNewVo.setLowPrice(product.getLowPrice().toString()); productNewVo.setStockNumber(Double.valueOf(product.getStockNumber())); List tbProductSkus = tbProductSkuRepository.searchSku(product.getId().toString()); - if ("sku".equals(product.getTypeEnum())){ - if(tbProductSkus.size() > 1){ + if ("sku".equals(product.getTypeEnum())) { + if (tbProductSkus.size() > 1) { BigDecimal maxPrice = tbProductSkus.stream().map(TbProductSku::getSalePrice).max(BigDecimal::compareTo).get(); if (maxPrice.compareTo(new BigDecimal(productNewVo.getLowPrice())) == 0) { - productNewVo.setLowPrice("¥" +productNewVo.getLowPrice()); - }else { - productNewVo.setLowPrice("¥" +productNewVo.getLowPrice() + "~¥" + maxPrice); + productNewVo.setLowPrice("¥" + productNewVo.getLowPrice()); + } else { + productNewVo.setLowPrice("¥" + productNewVo.getLowPrice() + "~¥" + maxPrice); } - }else { - productNewVo.setLowPrice("¥" +productNewVo.getLowPrice()); + } else { + productNewVo.setLowPrice("¥" + productNewVo.getLowPrice()); } } ViewConSku viewConSku = new ViewConSku(); @@ -265,7 +270,7 @@ public class TbProductServiceImpl implements TbProductService { viewConSku.setProductId(product.getId()); Example query = Example.of(viewConSku); List skuCons = viewConSkuRepository.findAll(query); - if(product.getTypeEnum().equals("sku")){ + if (product.getTypeEnum().equals("sku")) { //规格填充 productNewVo.setSkuList(convert(tbProductSkus)); //耗材弹窗选项 @@ -276,11 +281,11 @@ public class TbProductServiceImpl implements TbProductService { } } } - productNewVo.setConInfos(CollectionUtils.isEmpty(skuCons)? Collections.emptyList() :skuCons); + productNewVo.setConInfos(CollectionUtils.isEmpty(skuCons) ? Collections.emptyList() : skuCons); products.add(productNewVo); } Map result = PageUtil.toPage(products, page.getTotalElements()); - result.put("warnLine",warnLine); + result.put("warnLine", warnLine); return result; } @@ -303,9 +308,6 @@ public class TbProductServiceImpl implements TbProductService { public TbProductVo findByProductId(Integer id) throws Exception { TbProduct tbProduct = tbProductRepository.findById(id).orElseGet(TbProduct::new); - //单位 -// CompletableFuture tbShopUnits = CompletableFuture.supplyAsync(() -> -// tbShopUnitRepository.searchUnit(Integer.valueOf(StringUtils.isEmpty(tbProduct.getUnitId()) ? null : tbProduct.getUnitId()))); //sku CompletableFuture> tbProductSkus = CompletableFuture.supplyAsync(() -> tbProductSkuRepository.searchSku(tbProduct.getId().toString())); @@ -313,24 +315,20 @@ public class TbProductServiceImpl implements TbProductService { CompletableFuture tbProductSpec = CompletableFuture.supplyAsync(() -> tbProductSpecRepository.searchSpec(tbProduct.getSpecId())); -// Threads.call(tbShopUnits, tbProductSkus, tbProductSpec); Threads.call(tbProductSkus, tbProductSpec); //组装 TbProductVo tbProductVo = new TbProductVo(); -// tbProductVo.setStockNumber(tbProduct.getStockNumber() == null ? 0.00 : tbProduct.getStockNumber()); tbProductVo.setCategoryId(StringUtils.isNotBlank(tbProduct.getCategoryId()) ? Integer.valueOf(tbProduct.getCategoryId()) : null); - //单位 -// if (tbProduct.getUnitId() == null) { -// tbProductVo.setUnitId(null); -// tbProductVo.setUnitName(null); -// } - //套餐 - if (tbProduct.getGroupSnap() == null) { - tbProductVo.setGroupSnap(new JSONArray()); - } else { - tbProductVo.setGroupSnap(ListUtil.stringChangeList(tbProduct.getGroupSnap())); - } + BeanUtils.copyProperties(tbProduct, tbProductVo); + //套餐 + if (tbProduct.getType().equals("package")) { + if (tbProduct.getGroupSnap() == null) { + tbProductVo.setProGroupVo(null); + } else { + tbProductVo.setProGroupVo(JSONUtil.parseJSONStrTList(tbProduct.getGroupSnap(), ProductGroupVo.class)); + } + } tbProductVo.setStockNumber(Double.valueOf(tbProduct.getStockNumber())); if (!org.apache.commons.lang3.StringUtils.isBlank(tbProduct.getImages())) { tbProductVo.setImages(ListUtil.stringChangeList(tbProduct.getImages())); @@ -363,7 +361,7 @@ public class TbProductServiceImpl implements TbProductService { Optional skuResult = tbProductSkuResultRepository.findById(tbProductVo.getId()); tbProductVo.setSkuSnap(skuResult.get().getTagSnap()); } - if ("group".equals(tbProductVo.getTypeEnum())) { + if ("coupon".equals(tbProductVo.getType())) { if (StringUtils.isNotBlank(tbProduct.getGroupCategoryId())) { JSONArray objects = ListUtil.stringChangeList(tbProduct.getGroupCategoryId()); for (Object groupCategoryId : objects) { @@ -418,9 +416,9 @@ public class TbProductServiceImpl implements TbProductService { if (CollectionUtils.isEmpty(resources.getSkuList())) { throw new BadRequestException("商品规格不可为空"); } - if (!"group".equals(resources.getTypeEnum())) { + if (!"coupon".equals(resources.getType())) { if (resources.getCategoryId() == null) { - throw new BadRequestException("必填内容未填写"); + throw new BadRequestException("商品分类未填写"); } product.setCategoryId(String.valueOf(resources.getCategoryId())); } @@ -431,19 +429,16 @@ public class TbProductServiceImpl implements TbProductService { product.setImages(resources.getImages().toString()); } product.setIsDel(0); - product.setIsDelete(0); - product.setIsFreeFreight(1); product.setStatus(1); product.setCreatedAt(Instant.now().toEpochMilli()); product.setUpdatedAt(Instant.now().toEpochMilli()); List lowPrice = resources.getSkuList().stream().map(TbProductSku::getSalePrice).sorted().collect(Collectors.toList()); product.setLowPrice(lowPrice.get(0)); - if ("group".equals(resources.getTypeEnum())) { - //套餐内容 - if (!resources.getGroupSnap().isEmpty()) { - product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap())); - product.setIsCombo(1); - } + if ("coupon".equals(resources.getType())) { +// //套餐内容 +// if (!resources.getGroupSnap().isEmpty()) { +// product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap())); +// } if (!CollectionUtils.isEmpty(resources.getGroupCategoryId())) { List collect = resources.getGroupCategoryId().stream().map(TbCouponCategoryDto::getId).collect(Collectors.toList()); product.setGroupCategoryId(collect.toString()); @@ -454,6 +449,12 @@ public class TbProductServiceImpl implements TbProductService { } } } + if ("package".equals(resources.getType())) { + //套餐内容 + if (!resources.getProGroupVo().isEmpty()) { + product.setGroupSnap(ListUtil.listToJsonString(resources.getProGroupVo())); + } + } TbProduct save = tbProductRepository.save(product); if (save.getId() == null) { @@ -483,7 +484,7 @@ public class TbProductServiceImpl implements TbProductService { productSkuResult.setTagSnap(resources.getSkuSnap()); productSkuResult.setId(save.getId()); tbProductSkuResultRepository.save(productSkuResult); - } else if ("group".equals(resources.getTypeEnum())) { + } else if ("coupon".equals(resources.getType())) { TbPurchaseNotice notices = resources.getNotices(); if (StringUtils.isBlank(notices.getDateUsed()) && StringUtils.isBlank(notices.getAvailableTime()) @@ -528,28 +529,27 @@ public class TbProductServiceImpl implements TbProductService { throw new BadRequestException("规格数据异常"); } } - if (!"group".equals(product.getTypeEnum())) { + if (!"coupon".equals(product.getType())) { if (resources.getCategoryId() == null) throw new BadRequestException("商品分类不可为空"); - product.setIsCombo(0); product.setGroupSnap(null); if (resources.getNotices() != null && resources.getNotices().getId() != null && resources.getNotices().getId() > 0) { noticeRepository.deleteById(resources.getNotices().getId()); } } product.setIsDel(0); - product.setIsFreeFreight(1); product.setStatus(1); product.setUpdatedAt(Instant.now().toEpochMilli()); product.setImages(resources.getImages().toString()); product.setStockNumber(resources.getStockNumber().intValue()); List lowPrices = resources.getSkuList().stream().map(TbProductSku::getSalePrice).sorted().collect(Collectors.toList()); product.setLowPrice(lowPrices.get(0)); - if ("group".equals(resources.getTypeEnum())) { - //套餐内容 - if (!resources.getGroupSnap().isEmpty()) { - product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap())); - product.setIsCombo(1); - } + if ("coupon".equals(resources.getType())) { +// //套餐内容 +// if (!resources.getGroupSnap().isEmpty()) { +// product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap())); +// } else { +// throw new BadRequestException("套餐内容不可为空"); +// } if (!CollectionUtils.isEmpty(resources.getGroupCategoryId())) { List collect = resources.getGroupCategoryId().stream().map(TbCouponCategoryDto::getId).collect(Collectors.toList()); product.setGroupCategoryId(collect.toString()); @@ -564,6 +564,12 @@ public class TbProductServiceImpl implements TbProductService { } else { product.setCategoryId(resources.getCategoryId().toString()); } + if ("package".equals(resources.getType())) { + //套餐内容 + if (CollectionUtil.isNotEmpty(resources.getProGroupVo())) { + product.setGroupSnap(ListUtil.listToJsonString(resources.getProGroupVo())); + } + } TbProduct save = tbProductRepository.save(product); //sku @@ -590,7 +596,7 @@ public class TbProductServiceImpl implements TbProductService { tbProductSkuResultRepository.save(productSkuResult); } else { tbProductSkuResultRepository.deleteByIdN(save.getId()); - if ("group".equals(resources.getTypeEnum())) { + if ("coupon".equals(resources.getType())) { TbPurchaseNotice notices = resources.getNotices(); if (StringUtils.isBlank(notices.getDateUsed()) && StringUtils.isBlank(notices.getAvailableTime()) @@ -612,7 +618,6 @@ public class TbProductServiceImpl implements TbProductService { } - @Transactional(rollbackFor = Exception.class) @Override public void upProSort(TbProductSortCriteria param) { @@ -767,9 +772,13 @@ public class TbProductServiceImpl implements TbProductService { com.baomidou.mybatisplus.extension.plugins.pagination.Page page1 = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("is_del", 0) - .in("type_enum", "sku", "normal") + .eq(false, "type", "coupon") .eq("shop_id", shopId) .eq("status", 1) + .eq("is_del", 0) + .like("days", DateUtil.dayOfWeekEnum(new Date()).name()) + .gt("end_time", DateUtil.formatTime(new Date())) + .lt("start_time", DateUtil.formatTime(new Date())) .eq("is_pause_sale", 0); // 查询skuResult @@ -782,9 +791,19 @@ public class TbProductServiceImpl implements TbProductService { if (productId != null) { queryWrapper.eq("id", productId); } - + Map unitMap = new HashMap<>(); com.baomidou.mybatisplus.extension.plugins.pagination.Page tbProductPage = productMapper.selectPage(page1, queryWrapper); tbProductPage.getRecords().forEach(item -> { + if ("package".equals(item.getType())) { + item.setProGroupVo(JSONUtil.parseJSONStrTList(item.getGroupSnap(), ProductGroupVo.class)); + } + if (item.getUnitId() != null) { + if (!unitMap.containsKey(item.getUnitId())) { + TbShopUnit tbShopUnit = tbShopUnitRepository.searchUnit(item.getUnitId()); + unitMap.put(tbShopUnit.getId(), tbShopUnit.getName()); + } + item.setUnitName(unitMap.get(item.getUnitId())); + } TbProductSkuResult skuResult = productSkuResultRepository.findById(item.getId()).orElse(null); List tbProductSkus = producSkutMapper.selectList(new LambdaQueryWrapper().eq(TbProductSku::getIsDel, 0) .eq(TbProductSku::getIsPauseSale, 0) @@ -865,10 +884,4 @@ public class TbProductServiceImpl implements TbProductService { current.remove(current.size() - 1); // 回溯 } } - - public static void main(String[] args) { - String str="[{\"label\":\"温度\",\"value\":\"热,冰,少冰\"}]"; - str=str.replace("label", "name"); - System.out.println(str); - } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java index 8eba3b62..b6acf46b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java @@ -1,23 +1,24 @@ package cn.ysk.cashier.service.impl.shopimpl; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.qrcode.QrCodeUtil; -import cn.hutool.extra.qrcode.QrConfig; -import cn.ysk.cashier.config.security.security.TokenProvider; -import cn.ysk.cashier.config.security.service.UserCacheManager; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import cn.ysk.cashier.dto.BindingDto; import cn.ysk.cashier.dto.shop.TbShopInfoDto; import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.exception.EntityNotFoundException; import cn.ysk.cashier.mapper.shop.TbShopInfoMapper; -import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper; import cn.ysk.cashier.pojo.product.TbProductGroup; import cn.ysk.cashier.pojo.shop.TbMerchantAccount; import cn.ysk.cashier.pojo.shop.TbMerchantRegister; import cn.ysk.cashier.pojo.shop.TbPlussShopStaff; import cn.ysk.cashier.pojo.shop.TbShopInfo; import cn.ysk.cashier.repository.TbShopPayTypeRepository; -import cn.ysk.cashier.repository.shop.*; +import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository; +import cn.ysk.cashier.repository.shop.TbMerchantRegisterRepository; +import cn.ysk.cashier.repository.shop.TbPlussShopStaffRepository; +import cn.ysk.cashier.repository.shop.TbShopInfoRepository; +import cn.ysk.cashier.service.BindService; import cn.ysk.cashier.service.WxService; import cn.ysk.cashier.service.product.TbProductGroupService; import cn.ysk.cashier.service.shop.TbShopInfoService; @@ -30,11 +31,8 @@ import cn.ysk.cashier.system.repository.UserRepository; import cn.ysk.cashier.system.service.ParamsService; import cn.ysk.cashier.system.service.UserService; import cn.ysk.cashier.utils.*; -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; +import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.ResourceLoader; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -44,21 +42,18 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import javax.imageio.ImageIO; +import javax.persistence.criteria.Predicate; import javax.servlet.http.HttpServletResponse; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.InputStream; import java.time.Instant; import java.util.*; /** -* @website https://eladmin.vip -* @description 服务实现 -* @author lyf -* @date 2023-11-07 -**/ + * @author lyf + * @website https://eladmin.vip + * @description 服务实现 + * @date 2023-11-07 + **/ @Service @RequiredArgsConstructor public class TbShopInfoServiceImpl implements TbShopInfoService { @@ -73,8 +68,6 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { private final UserService userService; - private final UserCacheManager userCacheManager; - private final TokenProvider tokenProvider; private final ParamsService paramsService; private final TbMerchantRegisterRepository merchantRegisterRepository; @@ -86,16 +79,68 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { private final RedisUtils redisUtils; private final TbShopPayTypeRepository tbShopPayTypeRepository; + private final BindService bindService; private final WxService wxService; @Override - public Map queryAll(TbShopInfoQueryCriteria criteria){ + public JSONObject binding(BindingDto bindingDto) { + TbShopInfo tbShopInfo = tbShopInfoRepository.findById(bindingDto.getShopId()).orElseGet(null); + TbMerchantAccount account = merchantAccountRepository.findByAccount(tbShopInfo.getAccount()); + boolean isNew = true; + if (org.apache.commons.lang3.StringUtils.isBlank(bindingDto.getAccount())) { + if (tbShopInfo != null) { + if (org.apache.commons.lang3.StringUtils.isNotBlank(account.getBindAccount())) { + isNew = false; + bindingDto.setAccount(account.getBindAccount()); + } else { + return null; + } + } + } + Map param = new HashMap<>(); + param.put("account", bindingDto.getAccount()); + JSONObject data = bindService.binding(param); + if (isNew) { + account.setBindAccount(bindingDto.getAccount()); + account.setArticle(bindingDto.getArticle()); + account.setTaxAmount(bindingDto.getTaxAmount()); + account.setSdType(bindingDto.getSdType()); + merchantAccountRepository.save(account); + } + data.put("bindAccount", account.getBindAccount()); + data.put("article", account.getArticle()); + data.put("taxAmount", account.getTaxAmount()); + data.put("sdType", account.getSdType()); + return data; + } + + @Override + public Map queryAll(TbShopInfoQueryCriteria criteria) { Sort sort = Sort.by(Sort.Direction.DESC, "id"); Pageable pageables = PageRequest.of(criteria.getPage(), criteria.getSize(), sort); - Page page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageables); + Page page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageables); return PageUtil.toPage(page); } + @Override + public List queryChildShop(TbShopInfoQueryCriteria criteria) { + List list = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> { + Predicate query1 = criteriaBuilder.equal(root.get("id"), criteria.getId()); + Predicate query2 = criteriaBuilder.and( + criteriaBuilder.equal(root.get("mainId"), criteria.getId()), + criteriaBuilder.notEqual(root.get("type"), "only") + ); + + Predicate predicate = criteriaBuilder.or( + query1, + query2 + ); + criteriaBuilder.desc(root.get("tubeType")); + return predicate; + }); + return list; + } + // @Override // public List queryAll(TbShopInfoQueryCriteria criteria){ // return tbShopInfoMapper.toDto(tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); @@ -105,14 +150,14 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { @Transactional public TbShopInfoDto findById(Integer id) { TbShopInfo tbShopInfo = tbShopInfoRepository.findById(id).orElseGet(TbShopInfo::new); - if(StringUtils.isBlank(tbShopInfo.getSmallQrcode())){ + if (StringUtils.isBlank(tbShopInfo.getSmallQrcode())) { String smallQrcode = wxService.getSmallQrcode(id.toString()); tbShopInfo.setSmallQrcode(smallQrcode); tbShopInfoRepository.save(tbShopInfo); } String baseUrl = paramsService.getValue(ParamsEnum.SHOP_ORDER_PAY_BASE_URL.name()); - tbShopInfo.setPaymentQrcode(baseUrl+"?shopId="+id); - ValidationUtil.isNull(tbShopInfo.getId(),"TbShopInfo","id",id); + tbShopInfo.setPaymentQrcode(baseUrl + "?shopId=" + id); + ValidationUtil.isNull(tbShopInfo.getId(), "TbShopInfo", "id", id); return tbShopInfoMapper.toDto(tbShopInfo); } @@ -122,49 +167,53 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { return tbShopInfo; } - @Override - public TbShopInfoDto finByAccount(String account) { - return null; - } - @Override @Transactional(rollbackFor = Exception.class) public TbShopInfoDto create(TbShopInfoDto resources) { - if(StringUtils.isBlank(resources.getShopName())){ + if (StringUtils.isBlank(resources.getShopName())) { throw new BadRequestException("店铺名称不可为空"); } resources.setShopName(resources.getShopName().trim()); - if ("release".equals(resources.getProfiles())){ - if (resources.getRegisterCode() == null){ + if ("release".equals(resources.getProfiles())) { + if (resources.getRegisterCode() == null) { throw new BadRequestException("未绑定激活码"); } } TbShopInfo byAccount = tbShopInfoRepository.findByAccount(resources.getAccount()); User byUsername = userRepository.findByUsername(resources.getAccount()); - if (byAccount != null || byUsername != null){ + if (byAccount != null || byUsername != null) { throw new BadRequestException("登录名已注册"); } TbShopInfo tbShopInfo = new TbShopInfo(); - BeanUtils.copyProperties(resources,tbShopInfo); + BeanUtil.copyProperties(resources, tbShopInfo, CopyOptions.create().setIgnoreNullValue(true)); tbShopInfo.setCreatedAt(Instant.now().toEpochMilli()); tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli()); - tbShopInfo.setOnSale(1); tbShopInfo.setIsOpenYhq(resources.getIsOpenYhq()); //激活码 TbMerchantRegister tbMerchantRegister = new TbMerchantRegister(); - if (resources.getRegisterCode() != null){ + if (resources.getRegisterCode() != null) { tbMerchantRegister = merchantRegisterRepository.findByRegisterCode(resources.getRegisterCode()); - if(tbMerchantRegister == null){ + if (tbMerchantRegister == null) { throw new BadRequestException("激活码有误"); } - if (tbMerchantRegister.getStatus() == 1){ + if (tbMerchantRegister.getStatus() == 1) { throw new BadRequestException("激活码已激活,不能重复绑定"); } tbShopInfo.setExpireAt(DateUtil.addMonthsAndGetTimestamp(tbMerchantRegister.getPeriodYear())); //向redis中存入key - redisUtils.set(CacheKey.ACT_CODE+resources.getAccount(),"1",tbShopInfo.getExpireAt()-Instant.now().toEpochMilli()); + redisUtils.set(CacheKey.ACT_CODE + resources.getAccount(), "1", tbShopInfo.getExpireAt() - Instant.now().toEpochMilli()); } + + if (org.apache.commons.lang3.StringUtils.isNotBlank(resources.getType()) && !"only".equals(resources.getType())) { + if (resources.getMainId() == null) { + throw new BadRequestException("连锁店或者扩展店 主店铺不能为空"); + } + } else { + tbShopInfo.setMainId(null); + tbShopInfo.setTubeType(1); + } + //增加商户详情 TbShopInfo save = tbShopInfoRepository.save(tbShopInfo); if (resources.getRegisterCode() != null) { @@ -228,7 +277,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { shopStaffRepository.save(tbPlussShopStaff); //增加默认支付方式 Integer integer = tbShopPayTypeRepository.creatPayType(save.getId().toString()); - if (integer<4){ + if (integer < 4) { throw new BadRequestException("请重试"); } TbProductGroup tbProductGroup = new TbProductGroup(); @@ -243,27 +292,35 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { @Override @Transactional - public void upShopPass(String username,String password){ + public void upShopPass(String username, String password) { User user = userRepository.findByUsername(username); if (user == null) { throw new EntityNotFoundException(User.class, "username", username); } String encPass = MD5Utils.encrypt(password); - shopStaffRepository.updatePass(username,encPass,System.currentTimeMillis()); - merchantAccountRepository.updatePass(username,encPass,System.currentTimeMillis()); + shopStaffRepository.updatePass(username, encPass, System.currentTimeMillis()); + merchantAccountRepository.updatePass(username, encPass, System.currentTimeMillis()); // passwordEncoder.encode(passwordEncoder.encode(password)) - userService.updatePass(username,passwordEncoder.encode(password)); + userService.updatePass(username, passwordEncoder.encode(password)); } @Override @Transactional(rollbackFor = Exception.class) public void update(TbShopInfo resources) { TbShopInfo tbShopInfo = tbShopInfoRepository.findById(resources.getId()).orElseGet(TbShopInfo::new); - if (StringUtils.isNotBlank(resources.getShopName()) && !resources.getShopName().equals(tbShopInfo.getShopName())) { - shopStaffRepository.updateNameById(resources.getShopName(),resources.getId().toString()); - userRepository.updateNickName(resources.getAccount(),resources.getShopName()); + if (org.apache.commons.lang3.StringUtils.isNotBlank(resources.getType()) && !"only".equals(resources.getType())) { + if (resources.getMainId() == null) { + throw new BadRequestException("连锁店或者扩展店 主店铺不能为空"); + } + } else { + tbShopInfo.setMainId(null); + tbShopInfo.setTubeType(1); } - ValidationUtil.isNull( tbShopInfo.getId(),"TbShopInfo","id",resources.getId()); + if (StringUtils.isNotBlank(resources.getShopName()) && !resources.getShopName().equals(tbShopInfo.getShopName())) { + shopStaffRepository.updateNameById(resources.getShopName(), resources.getId().toString()); + userRepository.updateNickName(resources.getAccount(), resources.getShopName()); + } + ValidationUtil.isNull(tbShopInfo.getId(), "TbShopInfo", "id", resources.getId()); tbShopInfo.copy(resources); tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli()); tbShopInfoRepository.save(tbShopInfo); @@ -272,7 +329,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { @Override public void updateShopId(TbShopInfo resources) { TbShopInfo tbShopInfo = tbShopInfoRepository.findById(resources.getId()).orElseGet(TbShopInfo::new); - ValidationUtil.isNull( tbShopInfo.getId(),"TbShopInfo","id",resources.getId()); + ValidationUtil.isNull(tbShopInfo.getId(), "TbShopInfo", "id", resources.getId()); tbShopInfo.copy(resources); } @@ -293,7 +350,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { public void download(List all, HttpServletResponse response) throws IOException { List> list = new ArrayList<>(); for (TbShopInfoDto tbShopInfo : all) { - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); map.put("店铺帐号", tbShopInfo.getAccount()); map.put("店铺代号,策略方式为city +店铺号(8位)", tbShopInfo.getShopCode()); map.put("店铺口号", tbShopInfo.getSubTitle()); @@ -314,7 +371,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { map.put("经纬度", tbShopInfo.getLat()); map.put("经纬度", tbShopInfo.getLng()); map.put("未用", tbShopInfo.getMchId()); - map.put(" registerType", tbShopInfo.getRegisterType()); + map.put(" registerType", tbShopInfo.getRegisterType()); map.put("是否独立的微信小程序", tbShopInfo.getIsWxMaIndependent()); map.put("详细地址", tbShopInfo.getAddress()); map.put("类似于这种规则51.51.570", tbShopInfo.getCity()); @@ -323,7 +380,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { map.put("行业名称", tbShopInfo.getIndustryName()); map.put("营业时间", tbShopInfo.getBusinessTime()); map.put("配送时间", tbShopInfo.getPostTime()); - map.put(" postAmountLine", tbShopInfo.getPostAmountLine()); + map.put(" postAmountLine", tbShopInfo.getPostAmountLine()); map.put("0停业1,正常营业,网上售卖", tbShopInfo.getOnSale()); map.put("0今日,1次日", tbShopInfo.getSettleType()); map.put("时间", tbShopInfo.getSettleTime()); @@ -334,9 +391,9 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { map.put("订单等待时间", tbShopInfo.getOrderWaitPayMinute()); map.put("支持登陆设备个数", tbShopInfo.getSupportDeviceNumber()); map.put("分销层级(1-下级分销 2-两下级分销)", tbShopInfo.getDistributeLevel()); - map.put(" createdAt", tbShopInfo.getCreatedAt()); - map.put(" updatedAt", tbShopInfo.getUpdatedAt()); - map.put(" proxyId", tbShopInfo.getProxyId()); + map.put(" createdAt", tbShopInfo.getCreatedAt()); + map.put(" updatedAt", tbShopInfo.getUpdatedAt()); + map.put(" proxyId", tbShopInfo.getProxyId()); list.add(map); } FileUtil.downloadExcel(list, response); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopPurveyorTransactServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopPurveyorTransactServiceImpl.java index b9cb0253..3c9dfb2f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopPurveyorTransactServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopPurveyorTransactServiceImpl.java @@ -1,5 +1,8 @@ package cn.ysk.cashier.service.impl.shopimpl; +import cn.ysk.cashier.cons.domain.SuppFlow; +import cn.ysk.cashier.cons.domain.TbConsInfo; +import cn.ysk.cashier.cons.repository.TbConsInfoRepository; import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactDto; import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactQueryCriteria; import cn.ysk.cashier.exception.BadRequestException; @@ -11,10 +14,12 @@ import cn.ysk.cashier.repository.shop.TbShopPurveyorRepository; import cn.ysk.cashier.repository.shop.TbShopPurveyorTransactRepository; import cn.ysk.cashier.service.shop.TbShopPurveyorTransactService; import cn.ysk.cashier.utils.FileUtil; +import cn.ysk.cashier.utils.JSONUtil; import cn.ysk.cashier.utils.QueryHelp; import cn.ysk.cashier.utils.ValidationUtil; import cn.ysk.cashier.vo.PurveyorTransactVO; import lombok.RequiredArgsConstructor; +import org.apache.commons.lang3.StringUtils; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -26,6 +31,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; import java.util.*; +import java.util.stream.Collectors; /** * @author lyf @@ -39,6 +45,7 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact private final TbShopPurveyorTransactRepository tbShopPurveyorTransactRepository; private final TbShopPurveyorTransactMapper tbShopPurveyorTransactMapper; + private final TbConsInfoRepository tbConsInfoRepository; private final TbShopPurveyorRepository tbShopPurveyorRepository; private final TbShopPurveyorTransactPayService transactPayService; @@ -47,7 +54,15 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact Sort sort = Sort.by(Sort.Direction.DESC, "id"); Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort); Page pageShopPurveyor = tbShopPurveyorTransactRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); - + for (TbShopPurveyorTransact tbShopPurveyorTransact : pageShopPurveyor.getContent()) { + if (StringUtils.isNotBlank(tbShopPurveyorTransact.getConInfos())) { + List conInfos = JSONUtil.parseJSONStrTList(tbShopPurveyorTransact.getConInfos(), SuppFlow.ConInfos.class); + tbShopPurveyorTransact.setConFlows(conInfos); + List collect = conInfos.stream().map(SuppFlow.ConInfos::getConInfoId).collect(Collectors.toList()); + List cons = tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.in(root.get("id")).value(collect)); + tbShopPurveyorTransact.setCons(cons); + } + } Map map = new HashMap<>(); map.put("content", pageShopPurveyor.getContent()); map.put("totalElements", pageShopPurveyor.getTotalElements()); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index bfd12f27..2a5506b2 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateUtil; import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.config.security.security.TokenProvider; @@ -22,11 +23,13 @@ import cn.ysk.cashier.dto.points.OrderDeductionPointsDTO; import cn.ysk.cashier.dto.shop.TbShopTableDto; import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria; import cn.ysk.cashier.dto.shoptable.*; +import cn.ysk.cashier.dto.thirdcoupon.CheckCouponDTO; import cn.ysk.cashier.enums.*; import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.mapper.shop.TbShopTableMapper; import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord; import cn.ysk.cashier.mybatis.entity.TbShopCoupon; +import cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord; import cn.ysk.cashier.mybatis.mapper.*; import cn.ysk.cashier.mybatis.service.*; import cn.ysk.cashier.pojo.TbShopPayType; @@ -43,14 +46,12 @@ import cn.ysk.cashier.repository.product.TbProductSkuRepository; import cn.ysk.cashier.repository.shop.TbShopInfoRepository; import cn.ysk.cashier.repository.shop.TbShopTableRepository; import cn.ysk.cashier.service.PayService; +import cn.ysk.cashier.service.ThirdPartyCouponService; import cn.ysk.cashier.service.impl.TbPayServiceImpl; import cn.ysk.cashier.service.order.TbOrderInfoService; import cn.ysk.cashier.service.shop.TbShopTableService; import cn.ysk.cashier.utils.*; -import cn.ysk.cashier.vo.ActivateInInfoVO; -import cn.ysk.cashier.vo.OrderInfoUserCouponVo; -import cn.ysk.cashier.vo.PendingCountVO; -import cn.ysk.cashier.vo.TbUserCouponVo; +import cn.ysk.cashier.vo.*; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -125,12 +126,13 @@ public class TbShopTableServiceImpl implements TbShopTableService { private final MpShopInfoMapper mpShopInfoMapper; private final MpOrderDetailService mpOrderDetailService; private final MpCashierCartService mpCashierCartService; - private final MpMerchantThirdApplyMapper mpMerchantThirdApplyMapper; private final PayService payService; private final TbOrderInfoService orderInfoService; private final MpOrderInfoService mpOrderInfoService; private final TbShopUserMapper tbShopUserMapper; - private final TbActivateInRecordService activateInRecordService; + private final ThirdPartyCouponService thirdPartyCouponService; + private final TbThirdPartyCouponRecordService thirdPartyCouponRecordService; + private final TbCreditBuyerOrderService creditBuyerOrderService; private TbOrderInfo getCurrentOrder(ShopEatTypeInfoDTO eatTypeInfoDTO) { // 获取当前台桌最新订单,先付款模式不获取 @@ -261,6 +263,10 @@ public class TbShopTableServiceImpl implements TbShopTableService { query.eq(TbShopTable::getStatus, criteria.getState()).isNotNull(TbShopTable::getQrcode).ne(TbShopTable::getQrcode, ""); } + if (criteria.getIsPredate() != null) { + query.eq(TbShopTable::getIsPredate, criteria.getIsPredate()); + } + com.baomidou.mybatisplus.extension.plugins.pagination.Page shopTablePage = mpShopTableService.page(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(criteria.getPage(), criteria.getSize()), query); List tbShopTableList = shopTablePage.getRecords(); @@ -441,6 +447,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException("商品不存在或已下架, id: " + updateCartDTO.getSkuId()); } + resetGroupProductCart(updateCartDTO.getGroupProductIdList(), product, tbCashierCart); tbCashierCart.setCoverImg(product.getCoverImg()); tbCashierCart.setIsSku(product.getTypeEnum()); tbCashierCart.setName(product.getName()); @@ -458,6 +465,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setTotalAmount(updateCartDTO.getNum().multiply(tbCashierCart.getSalePrice())); tbCashierCart.setNote(updateCartDTO.getNote()); tbCashierCart.setIsPrint(updateCartDTO.getIsPrint()); + tbCashierCart.setIsWaitCall(updateCartDTO.getIsWaitCall()); if (updateCartDTO.getIsPack() != null) { if (!updateCartDTO.getIsPack()) { @@ -476,6 +484,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (updateCartDTO.getIsGift() != null) { tbCashierCart.setTotalAmount(updateCartDTO.getIsGift() ? tbCashierCart.getPackFee() : tbCashierCart.getTotalAmount()); tbCashierCart.setIsGift(updateCartDTO.getIsGift() ? "true" : "false"); + tbCashierCart.setDiscountSaleAmount(BigDecimal.ZERO); + if (updateCartDTO.getIsGift()) { + tbCashierCart.setDiscountSaleNote(""); + tbCashierCart.resetTotalAmount(); + } } tbCashierCart.setTotalNumber(updateCartDTO.getNum()); @@ -485,6 +498,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (tbCashierCart.getOrderId() != null && StrUtil.isNotBlank(updateCartDTO.getNote())) { orderDetailMapper.update(null, new LambdaUpdateWrapper() .eq(TbOrderDetail::getCartId, tbCashierCart.getId()) + .set(TbOrderDetail::getProGroupInfo, tbCashierCart.getProGroupInfo()) + .set(TbOrderDetail::getIsWaitCall, updateCartDTO.getIsWaitCall()) .set(TbOrderDetail::getNote, updateCartDTO.getNote())); } @@ -502,6 +517,51 @@ public class TbShopTableServiceImpl implements TbShopTableService { return orderInfo == null ? 1 : orderInfo.getPlaceNum() + 1; } + /** + * 重置购物车套餐商品信息 + */ + private void resetGroupProductCart(List productIds, TbProduct product, TbCashierCart cashierCart) { + boolean isChoseGroup = TableConstant.Product.Type.PACKAGE.equalsVals(product.getType()) && product.getGroupType() == 1; + boolean isFixGroup = TableConstant.Product.Type.PACKAGE.equalsVals(product.getType()) && product.getGroupType() == 0; + if (isChoseGroup && productIds != null && !productIds.isEmpty()) { + String groupSnap = product.getGroupSnap(); + if (StrUtil.isNotBlank(groupSnap)) { + ArrayList foods = new ArrayList<>(); + HashMap groupVoHashMap = new HashMap<>(); + JSONObject.parseArray(groupSnap).forEach(item -> { + ProductGroupVo productGroupVo = ((JSONObject) item).toJavaObject(ProductGroupVo.class); + productGroupVo.getGoods().forEach(goods -> { + groupVoHashMap.put(goods.getProId().toString(), goods); + }); + }); + + productIds.forEach(item -> { + ProductGroupVo.Food food = groupVoHashMap.get(item.toString()); + if (food == null) { + throw new BadRequestException("存在无效套餐商品"); + } + foods.add(food); + }); + + cashierCart.setProGroupInfo(JSONObject.toJSONString(foods)); + } + } else if (isFixGroup) { + String groupSnap = product.getGroupSnap(); + if (StrUtil.isNotBlank(groupSnap)) { + ArrayList foods = new ArrayList<>(); + HashMap groupVoHashMap = new HashMap<>(); + JSONObject.parseArray(groupSnap).forEach(item -> { + ProductGroupVo productGroupVo = ((JSONObject) item).toJavaObject(ProductGroupVo.class); + productGroupVo.getGoods().forEach(goods -> { + groupVoHashMap.put(goods.getProId().toString(), goods); + }); + }); + + cashierCart.setProGroupInfo(JSONObject.toJSONString(groupVoHashMap.values())); + } + } + } + @Override public TbCashierCart addCartForUser(AddCartDTO addCartDTO) { addCartDTO.setTableId(OrderUseTypeEnum.TAKEOUT.getValue().equals(addCartDTO.getUseType()) ? null : addCartDTO.getTableId()); @@ -518,6 +578,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException(product.getName() + "商品库存不足"); } + boolean isChoseGroup = TableConstant.Product.Type.PACKAGE.equalsVals(product.getType()) && product.getGroupType() == 1; + if (isChoseGroup && (addCartDTO.getGroupProductIdList() == null || addCartDTO.getGroupProductIdList().isEmpty())) { + throw new BadRequestException("可选套餐,请先选择套餐商品"); + } + LambdaQueryWrapper query = new LambdaQueryWrapper() .eq(TbCashierCart::getShopId, addCartDTO.getShopId()) .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) @@ -545,6 +610,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 首次加入 if (tbCashierCart == null) { tbCashierCart = new TbCashierCart(); + resetGroupProductCart(addCartDTO.getGroupProductIdList(), product, tbCashierCart); + TbShopUnit tbShopUnit = mpShopUnitMapper.selectById(product.getUnitId()); + if (tbShopUnit != null) { + tbCashierCart.setUnit(tbShopUnit.getName()); + } + tbCashierCart.setTypeEnum(product.getTypeEnum()); tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType()); tbCashierCart.setCoverImg(product.getCoverImg()); tbCashierCart.setCreatedAt(System.currentTimeMillis()); @@ -585,9 +656,10 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && addCartDTO.getVipUserId() != null ? 1 : 0); tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : addCartDTO.getVipUserId() == null ? 0 : 1); tbCashierCart.setMemberPrice(productSku.getMemberPrice()); - cashierCartRepository.save(tbCashierCart); + mpCashierCartService.save(tbCashierCart); } else { + resetGroupProductCart(addCartDTO.getGroupProductIdList(), product, tbCashierCart); tbCashierCart.setIsMember(!shopEatTypeInfoDTO.isMemberPrice() ? 0 : addCartDTO.getVipUserId() == null ? 0 : 1); tbCashierCart.setNote(addCartDTO.getNote()); tbCashierCart.setTotalAmount(addCartDTO.getNum().multiply(productSku.getSalePrice())); @@ -627,59 +699,40 @@ public class TbShopTableServiceImpl implements TbShopTableService { @Override public TbCashierCart addTemporaryDishes(AddTemporaryDishesDTO temporaryDishesDTO) { -// temporaryDishesDTO.setTableId(OrderUseTypeEnum.TAKEOUT.getValue().equals(temporaryDishesDTO.getUseType()) ? null : temporaryDishesDTO.getTableId()); -// ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(temporaryDishesDTO.getShopId(), temporaryDishesDTO.getTableId(), temporaryDishesDTO.getUseType()); + temporaryDishesDTO.setTableId(OrderUseTypeEnum.TAKEOUT.getValue().equals(temporaryDishesDTO.getUseType()) ? null : temporaryDishesDTO.getTableId()); + ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(temporaryDishesDTO.getShopId(), temporaryDishesDTO.getTableId(), temporaryDishesDTO.getUseType()); // -// TbCashierCart tbCashierCart = mpCashierCartService.selectOneCartByShopEatType(shopEatTypeInfoDTO, temporaryDishesDTO.getMasterId(), null, null, false, true); -// // 首次加入 -// if (tbCashierCart == null) { -// tbCashierCart = new TbCashierCart(); -// tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType()); -// tbCashierCart.setCreatedAt(System.currentTimeMillis()); -// tbCashierCart.setIsSku("0"); -// if (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) { -// tbCashierCart.setTableId(shopEatTypeInfoDTO.getTableId()); -// } -// tbCashierCart.setName(temporaryDishesDTO.getName()); -// tbCashierCart.setSalePrice(temporaryDishesDTO.getPrice()); -// tbCashierCart.setMasterId(temporaryDishesDTO.getMasterId()); -// tbCashierCart.setShopId(String.valueOf(temporaryDishesDTO.getShopId())); -// tbCashierCart.setTradeDay(DateUtils.getDay()); -// tbCashierCart.setStatus("create"); -// tbCashierCart.setIsPack("false"); -// tbCashierCart.setIsGift("false"); -// tbCashierCart.setTotalAmount(temporaryDishesDTO.getNum().multiply(temporaryDishesDTO.getPrice())); -// tbCashierCart.setPackFee(BigDecimal.ZERO); -// tbCashierCart.setTotalNumber(temporaryDishesDTO.getNum()); -// tbCashierCart.setNumber(temporaryDishesDTO.getNum()); -// tbCashierCart.setCategoryId(String.valueOf(temporaryDishesDTO.getCategoryId())); -// tbCashierCart.setNote(temporaryDishesDTO.getNote()); -// tbCashierCart.setPlatformType(OrderPlatformTypeEnum.PC.getValue()); -// tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && temporaryDishesDTO.getVipUserId() != null ? 1 : 0); -// tbCashierCart.setIsTemporary(1); -// tbCashierCart.setUnit(temporaryDishesDTO.getUnit()); -// cashierCartRepository.save(tbCashierCart); -// -// } else { -// tbCashierCart.setIsMember(temporaryDishesDTO.getVipUserId() == null ? 0 : 1); -// tbCashierCart.setNote(temporaryDishesDTO.getNote()); -// tbCashierCart.setTotalAmount(temporaryDishesDTO.getNum().multiply(temporaryDishesDTO.getPrice())); -// tbCashierCart.setPackFee(BigDecimal.ZERO); -// tbCashierCart.setIsPack("false"); -// tbCashierCart.setIsGift("false"); -// tbCashierCart.setTotalNumber(temporaryDishesDTO.getNum()); -// tbCashierCart.setNumber(temporaryDishesDTO.getNum()); -// tbCashierCart.setUpdatedAt(DateUtil.current()); -// tbCashierCart.setIsTemporary(1); -// tbCashierCart.setUnit(temporaryDishesDTO.getUnit()); -// cashierCartMapper.updateById(tbCashierCart); -// } -// -// if (StrUtil.isNotBlank(temporaryDishesDTO.getTableId())) { -// setRedisTableCartInfo(temporaryDishesDTO.getTableId(), temporaryDishesDTO.getShopId().toString(), Collections.singletonList(tbCashierCart), true); -// } -// return tbCashierCart; - return null; + TbCashierCart tbCashierCart = new TbCashierCart(); + tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType()); + tbCashierCart.setCreatedAt(System.currentTimeMillis()); + tbCashierCart.setIsSku("0"); + if (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) { + tbCashierCart.setTableId(shopEatTypeInfoDTO.getTableId()); + } + tbCashierCart.setName(temporaryDishesDTO.getName()); + tbCashierCart.setSalePrice(temporaryDishesDTO.getPrice()); + tbCashierCart.setMasterId(temporaryDishesDTO.getMasterId()); + tbCashierCart.setShopId(String.valueOf(temporaryDishesDTO.getShopId())); + tbCashierCart.setTradeDay(DateUtils.getDay()); + tbCashierCart.setStatus("create"); + tbCashierCart.setIsPack("false"); + tbCashierCart.setIsGift("false"); + tbCashierCart.setTotalAmount(temporaryDishesDTO.getNum().multiply(temporaryDishesDTO.getPrice())); + tbCashierCart.setPackFee(BigDecimal.ZERO); + tbCashierCart.setTotalNumber(temporaryDishesDTO.getNum()); + tbCashierCart.setNumber(temporaryDishesDTO.getNum()); + tbCashierCart.setCategoryId(String.valueOf(temporaryDishesDTO.getCategoryId())); + tbCashierCart.setNote(temporaryDishesDTO.getNote()); + tbCashierCart.setPlatformType(OrderPlatformTypeEnum.PC.getValue()); + tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && temporaryDishesDTO.getVipUserId() != null ? 1 : 0); + tbCashierCart.setIsTemporary(1); + tbCashierCart.setUnit(temporaryDishesDTO.getUnit()); + cashierCartRepository.save(tbCashierCart); + + if (StrUtil.isNotBlank(temporaryDishesDTO.getTableId())) { + setRedisTableCartInfo(temporaryDishesDTO.getTableId(), temporaryDishesDTO.getShopId().toString(), Collections.singletonList(tbCashierCart), true); + } + return tbCashierCart; } private void setRedisTableCartInfo(String tableId, String shopId, List tbCashierCartList, boolean isAdd) { @@ -915,44 +968,45 @@ public class TbShopTableServiceImpl implements TbShopTableService { AtomicReference mealCashierCart = new AtomicReference<>(); + List skuList = new ArrayList<>(); if (!skuIds.isEmpty()) { - List skuList = productSkuRepository.findAllById(skuIds); - HashMap skuMap = new HashMap<>(); - skuList.forEach(item -> skuMap.put(item.getId().toString(), item)); - - ArrayList> infos = new ArrayList<>(); - records.forEach(item -> { - if (item.getProductId() != null && item.getProductId().equals("-999")) { - mealCashierCart.set(item); - return; - } - Map map = BeanUtil.beanToMap(item, false, false); - TbProductSku tbProductSku = skuMap.get(item.getSkuId()); - map.put("specSnap", tbProductSku != null ? tbProductSku.getSpecSnap() : null); - map.put("placeNum", item.getPlaceNum() == null ? 0 : item.getPlaceNum()); - infos.add(map); - }); - - com.baomidou.mybatisplus.extension.plugins.pagination.Page copyPage = BeanUtil.copyProperties(cartPage, com.baomidou.mybatisplus.extension.plugins.pagination.Page.class); - - // 根据placeNum进行分组 - Map>> groupedByPlaceNum = infos.stream() - .collect(Collectors.groupingBy(info -> info.get("placeNum"))); - - ArrayList> list = new ArrayList<>(); - groupedByPlaceNum.forEach((k, v) -> { - HashMap item = new HashMap<>(); - item.put("placeNum", k); - item.put("info", v); - list.add(item); - }); - copyPage.setRecords(list); - Map map = BeanUtil.beanToMap(copyPage, false, false); - map.put("seatFee", mealCashierCart); - return map; + skuList = productSkuRepository.findAllById(skuIds); } + HashMap skuMap = new HashMap<>(); + skuList.forEach(item -> skuMap.put(item.getId().toString(), item)); - return BeanUtil.beanToMap(cartPage); + ArrayList> infos = new ArrayList<>(); + records.forEach(item -> { + if (item.getProductId() != null && item.getProductId().equals("-999")) { + mealCashierCart.set(item); + return; + } + Map map = BeanUtil.beanToMap(item, false, false); + TbProductSku tbProductSku = skuMap.get(item.getSkuId()); + map.put("specSnap", tbProductSku != null ? tbProductSku.getSpecSnap() : null); + map.put("placeNum", item.getPlaceNum() == null ? 0 : item.getPlaceNum()); + infos.add(map); + }); + + com.baomidou.mybatisplus.extension.plugins.pagination.Page copyPage = BeanUtil.copyProperties(cartPage, com.baomidou.mybatisplus.extension.plugins.pagination.Page.class); + + // 根据placeNum进行分组 + Map>> groupedByPlaceNum = infos.stream() + .collect(Collectors.groupingBy(info -> info.get("placeNum"))); + + ArrayList> list = new ArrayList<>(); + groupedByPlaceNum.forEach((k, v) -> { + HashMap item = new HashMap<>(); + item.put("placeNum", k); + item.put("info", v); + list.add(item); + }); + copyPage.setRecords(list); + Map map = BeanUtil.beanToMap(copyPage, false, false); + map.put("seatFee", mealCashierCart); + return map; + +// return BeanUtil.beanToMap(cartPage); } @Override @@ -1242,11 +1296,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 创建订单详情 OrderPriceDTO detailPriceDTO = createOrderDetailWithCoupon(cartInfoDTO.getCashierCarts(), orderInfo, - createOrderDTO.getShopId(), true, shopEatTypeInfoDTO); + createOrderDTO.getShopId(), true, shopEatTypeInfoDTO, createOrderDTO.getIsWaitCall()); // 是否是第一次创建订单 orderInfo = createOrderWithAction(createOrderDTO, detailPriceDTO, shopEatTypeInfoDTO, - orderInfo, cartInfoDTO.getSeatCart(), shopUser, shopTable); + orderInfo, cartInfoDTO.getSeatCart(), shopUser, shopTable, createOrderDTO.getIsWaitCall()); // 修改订单详情并打票 updateDetailAndPrint(orderInfo, detailPriceDTO, shopEatTypeInfoDTO); @@ -1522,7 +1576,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { private void returnCoupon(TbOrderInfo orderInfo, boolean resetInfo) { // 返还优惠券 - if (StrUtil.isNotBlank(orderInfo.getCouponInfoList())) { + if (StrUtil.isNotBlank(orderInfo.getCouponInfoList()) && !"null".equals(orderInfo.getCouponInfoList())) { OrderInfoCouponInfoDTO couponInfoDTO = JSONObject.parseObject(orderInfo.getCouponInfoList(), OrderInfoCouponInfoDTO.class); ArrayList couponIds = new ArrayList<>(); couponInfoDTO.getProductCoupon().forEach(item -> { @@ -1559,7 +1613,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { * @param updateState * @return */ - private OrderPriceDTO createOrderDetailWithCoupon(List fullCashierCarts, TbOrderInfo orderInfo, Integer shopId, boolean updateState, ShopEatTypeInfoDTO shopEatTypeInfoDTO) { + private OrderPriceDTO createOrderDetailWithCoupon(List fullCashierCarts, TbOrderInfo orderInfo, Integer shopId, + boolean updateState, ShopEatTypeInfoDTO shopEatTypeInfoDTO, Integer isWaitCall) { OrderPriceDTO priceDTO = new OrderPriceDTO(); List cartIds = fullCashierCarts.stream().map(TbCashierCart::getId).collect(Collectors.toList()); @@ -1577,6 +1632,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { }); for (TbCashierCart cashierCart : fullCashierCarts) { + if (isWaitCall != null) { + cashierCart.setIsWaitCall(isWaitCall); + } if (orderInfo != null && shopEatTypeInfoDTO != null) { cashierCart.setIsMember(StrUtil.isBlank(orderInfo.getMemberId()) ? 0 : shopEatTypeInfoDTO.isMemberPrice() ? 1 : 0); } @@ -1616,6 +1674,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setProductId(Integer.valueOf(cashierCart.getProductId())); } + orderDetail.setProGroupInfo(cashierCart.getProGroupInfo()); + orderDetail.setDiscountSaleAmount(cashierCart.getDiscountSaleAmount()); + orderDetail.setIsWaitCall(cashierCart.getIsWaitCall()); orderDetail.setUserCouponId(cashierCart.getUserCouponId()); orderDetail.setMemberPrice(cashierCart.getMemberPrice()); orderDetail.setNote(cashierCart.getNote()); @@ -1638,13 +1699,14 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderDetail.setIsMember(cashierCart.getIsMember()); orderDetail.setIsPrint(cashierCart.getIsPrint()); orderDetail.setUseCouponInfo(cashierCart.getUseCouponInfo()); + priceDTO.getOrderDetailList().add(orderDetail); } return priceDTO; } private TbOrderInfo createOrderWithAction(CreateOrderDTO createOrderDTO, OrderPriceDTO priceDTO, ShopEatTypeInfoDTO eatTypeInfoDTO, - TbOrderInfo orderInfo, TbCashierCart seatCart, TbShopUser shopUser, TbShopTable shopTable) { + TbOrderInfo orderInfo, TbCashierCart seatCart, TbShopUser shopUser, TbShopTable shopTable, Integer isWaitCall) { int placeNum = getCurrentPlaceNum(eatTypeInfoDTO); boolean isFirst = false; // 修改订单信息 @@ -1670,6 +1732,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderInfo.setMerchantId(merchantAccount.getId().toString()); orderInfo.setIsPostpaid(eatTypeInfoDTO.isDineInAfter() ? 1 : 0); } + orderInfo.setIsWaitCall(isWaitCall); // 更新取餐号 orderInfo.setOutNumber(updateOutNumber(String.valueOf(createOrderDTO.getShopId())).toString()); orderInfo.setUpdatedAt(System.currentTimeMillis()); @@ -2026,6 +2089,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { TbActivateOutRecord tbActivateOutRecord = null; if (!couponInfo.getFullReductionCouponMap().isEmpty()) { TbUserCouponVo couponVo = couponInfo.getFullReductionCouponMap().values().stream().findFirst().orElse(null); + couponVo.setCurrentUseNum(BigDecimal.ONE); finalAmount = finalAmount.subtract(couponVo.getDiscountAmount()); orderInfo.setFullCouponDiscountAmount(couponVo.getDiscountAmount()); @@ -2111,14 +2175,14 @@ public class TbShopTableServiceImpl implements TbShopTableService { return productDiscount; } - private void updateOrderDetailCanReturn(List orderDetailList, TbOrderInfo orderInfo) { + private void updateOrderDetailCanReturn(List orderDetailList, TbOrderInfo orderInfo) { orderDetailList = orderDetailList.stream().filter(item -> TableConstant.OrderInfo.Status.UNPAID.equalsVals(item.getStatus())).collect(Collectors.toList()); BigDecimal totalAmount = BigDecimal.ZERO; BigDecimal lastAmount = BigDecimal.ZERO; BigDecimal lastReturnAmount = BigDecimal.ZERO; BigDecimal orderAmount = orderInfo.getOrderAmount(); for (TbOrderDetail orderDetail : orderDetailList) { - totalAmount = totalAmount.add(orderDetail.getPriceAmount()); + totalAmount = totalAmount.add(orderDetail.getPriceAmount()); } for (TbOrderDetail item : orderDetailList) { if (StrUtil.isNotBlank(orderInfo.getCouponInfoList()) || orderInfo.getPointsNum() != null) { @@ -2127,7 +2191,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { lastReturnAmount = canReturnAmount; lastAmount = item.getPriceAmount(); item.setCanReturnAmount(canReturnAmount); - }else { + } else { item.setCanReturnAmount(item.getPriceAmount()); } } @@ -2152,7 +2216,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 获取优惠券信息 OrderCouponInfoDTO couponInfo = new OrderCouponInfoDTO(); - if (!payDTO.getUserCouponInfos().isEmpty()) { + if (payDTO.getUserCouponInfos() != null && !payDTO.getUserCouponInfos().isEmpty()) { couponInfo = getCouponInfo(payDTO.getVipUserId(), payDTO.getShopId(), payDTO.getUserCouponInfos(), orderInfo.getOrderAmount(), productIdSet); } @@ -2162,7 +2226,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { // 更新订单信息 ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(orderInfo.getShopId(), orderInfo.getTableId()); - OrderPriceDTO priceDTO = createOrderDetailWithCoupon(activateCartInfo, orderInfo, payDTO.getShopId(), false, shopEatTypeInfoDTO); + OrderPriceDTO priceDTO = createOrderDetailWithCoupon(activateCartInfo, orderInfo, payDTO.getShopId(), false, shopEatTypeInfoDTO, null); BigDecimal finalAmount = priceDTO.getTotalAmount().setScale(2, RoundingMode.HALF_UP); orderInfo.setUpdatedAt(System.currentTimeMillis()); @@ -2212,11 +2276,11 @@ public class TbShopTableServiceImpl implements TbShopTableService { List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId()); List detailList = mpOrderDetailService.selectByOrderId(orderInfo.getId()); BigDecimal discount = payDTO.getDiscount().setScale(4, RoundingMode.HALF_DOWN); - BigDecimal totalAmount = BigDecimal.ZERO; + BigDecimal sumTotalAmount = cashierCarts.stream().map(TbCashierCart::getTotalAmount).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal totalAmount = NumberUtil.mul(sumTotalAmount, discount).setScale(2, RoundingMode.HALF_UP); for (TbCashierCart cashierCart : cashierCarts) { if (cashierCart.getUserCouponId() == null) { - cashierCart.setTotalAmount(cashierCart.getTotalAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); - totalAmount = cashierCart.getTotalAmount(); + cashierCart.setTotalAmount(cashierCart.getTotalAmount().multiply(discount).setScale(2, RoundingMode.HALF_EVEN)); } // item.setSalePrice(item.getSalePrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); // item.setMemberPrice(item.getMemberPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); @@ -2224,7 +2288,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { } detailList.forEach(item -> { - item.setPriceAmount(item.getPriceAmount().multiply(discount).setScale(2, RoundingMode.HALF_UP)); + item.setPriceAmount(item.getPriceAmount().multiply(discount).setScale(2, RoundingMode.HALF_EVEN)); // item.setPrice(item.getPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); // item.setMemberPrice(item.getMemberPrice().multiply(discount).setScale(2, RoundingMode.HALF_UP)); }); @@ -2275,7 +2339,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { payDTO.setDiscount(new BigDecimal("1")); } - BigDecimal finalAmount = null; + BigDecimal finalAmount; // 计算优惠券积分折扣信息 if (payDTO.getVipUserId() != null) { @@ -2292,6 +2356,14 @@ public class TbShopTableServiceImpl implements TbShopTableService { boolean isOnline = false; switch (payDTO.getPayType()) { + case "creditBuyer": + if (payDTO.getCreditBuyerId() == null) { + throw new BadRequestException("挂单人不为空"); + } + creditBuyerOrderService.save(payDTO.getCreditBuyerId(), Long.valueOf(orderInfo.getId())); + orderInfo.setPayType(TableConstant.OrderInfo.PayType.CREDIT_BUYER.getValue()); + orderInfo.setCreditBuyerId(payDTO.getCreditBuyerId()); + break; case "vipPay": if (payDTO.getVipUserId() != null) { orderInfo.setUserId(String.valueOf(payDTO.getVipUserId())); @@ -2316,6 +2388,28 @@ public class TbShopTableServiceImpl implements TbShopTableService { case "deposit": orderInfo = tbPayServiceImpl.memberAccountPay("", String.valueOf(payDTO.getShopId()), payDTO.getCode(), orderInfo, finalAmount); break; + // 团购券支付 + case "partyCoupon": + if (payDTO.getNum() == null || payDTO.getNum() < 1) { + throw new BadRequestException("团购券核销数量有误"); + } + CheckCouponDTO dto = new CheckCouponDTO(); + dto.setNum(1); + dto.setShopId(payDTO.getShopId()); + dto.setCouponCode(payDTO.getCode()); + thirdPartyCouponService.checkCoupon(dto); + orderInfo.setOrderType(TableConstant.OrderInfo.OrderType.COUPON.getValue()); + TbThirdPartyCouponRecord record = new TbThirdPartyCouponRecord(); + record.setOrderId(orderInfo.getId()); + record.setCode(payDTO.getCode()); + record.setNum(1); + record.setState((byte) 1); + record.setPlat(TableConstant.ThirdPartyCoupon.Plat.MEI_TUAN.getValue()); + record.setCreateTime(DateUtil.date().toInstant()); + record.setCheckTime(DateUtil.date().toInstant()); + record.setShopId(payDTO.getShopId()); + thirdPartyCouponRecordService.save(record); + break; default: throw new BadRequestException("未知支付方式"); } @@ -2714,34 +2808,41 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (OrderUseTypeEnum.TAKEOUT.getValue().equals(choseModelDTO.getUseType())) { ArrayList productIds = new ArrayList<>(); cashierCarts.forEach(item -> { - productIds.add(Integer.valueOf(item.getProductId())); + if (item.getProductId() != null) { + productIds.add(Integer.valueOf(item.getProductId())); + } }); - List productList = productMapper.selectBatchIds(productIds); - Map productMap = productList.stream() - .collect(Collectors.toMap(product -> String.valueOf(product.getId()), product -> product)); - cashierCarts.forEach(item -> { - TbProduct product = productMap.get(item.getProductId()); + + Map productMap = new HashMap<>(); + if (!productIds.isEmpty()) { + List productList = productMapper.selectBatchIds(productIds); + productMap = productList.stream() + .collect(Collectors.toMap(product -> String.valueOf(product.getId()), product -> product)); + } + for (TbCashierCart cashierCart : cashierCarts) { + TbProduct product = productMap.get(cashierCart.getProductId()); + // 设置打包费 mpCashierCartService.update(new LambdaUpdateWrapper() - .eq(TbCashierCart::getId, item.getId()) - .set(TbCashierCart::getPackFee, product.getPackFee() != null ? - product.getPackFee().multiply(item.getNumber()) : BigDecimal.ZERO) + .eq(TbCashierCart::getId, cashierCart.getId()) + .set(TbCashierCart::getPackFee, product != null && product.getPackFee() != null ? + product.getPackFee().multiply(cashierCart.getNumber()) : BigDecimal.ZERO) .set(TbCashierCart::getTableId, null) .set(TbCashierCart::getUseType, OrderUseTypeEnum.TAKEOUT.getValue()) .set(TbCashierCart::getIsPack, "true")); - }); + } List detailList = orderDetailMapper.selectList(new LambdaQueryWrapper() .in(TbOrderDetail::getCartId, choseModelDTO.getCartIds()) .eq(TbOrderDetail::getShopId, choseModelDTO.getShopId())); - detailList.forEach(item -> { + for (TbOrderDetail item : detailList) { item.setUseType(OrderUseTypeEnum.TAKEOUT.getValue()); TbProduct product = productMap.get(item.getProductId().toString()); // 设置打包费 - item.setPackAmount(product.getPackFee() != null ? + item.setPackAmount(product != null && product.getPackFee() != null ? product.getPackFee().multiply(item.getNum()) : BigDecimal.ZERO); - }); + } if (!detailList.isEmpty()) { mpOrderDetailService.updateBatchById(detailList); @@ -2775,16 +2876,31 @@ public class TbShopTableServiceImpl implements TbShopTableService { detailIds.add(item.getId()); returnNumMap.put(item.getId().toString(), item.getNum()); }); - List detailList = orderDetailMapper.selectList(new LambdaQueryWrapper() - .eq(TbOrderDetail::getShopId, returnOrderDTO.getShopId()) - .eq(TbOrderDetail::getStatus, "closed") - .eq(TbOrderDetail::getOrderId, returnOrderDTO.getOrderId()) - .in(TbOrderDetail::getId, detailIds) - .orderByDesc(TbOrderDetail::getUserCouponId)); - if (detailList.size() != returnOrderDTO.getOrderDetails().size()) { - throw new BadRequestException("订单明细数量不一致"); + + List detailList = null; + if (TableConstant.OrderInfo.PayType.CREDIT_BUYER.equalsVals(oldOrderInfo.getPayType())) { + detailList = orderDetailMapper.selectList(new LambdaQueryWrapper() + .eq(TbOrderDetail::getShopId, returnOrderDTO.getShopId()) + .eq(TbOrderDetail::getStatus, "closed") + .eq(TbOrderDetail::getOrderId, returnOrderDTO.getOrderId()) + .orderByDesc(TbOrderDetail::getUserCouponId)); + + if (detailList.size() != returnOrderDTO.getOrderDetails().size()) { + throw new BadRequestException("挂账退款必须全退"); + } + } else { + detailList = orderDetailMapper.selectList(new LambdaQueryWrapper() + .eq(TbOrderDetail::getShopId, returnOrderDTO.getShopId()) + .eq(TbOrderDetail::getStatus, "closed") + .eq(TbOrderDetail::getOrderId, returnOrderDTO.getOrderId()) + .in(TbOrderDetail::getId, detailIds) + .orderByDesc(TbOrderDetail::getUserCouponId)); + if (detailList.size() != returnOrderDTO.getOrderDetails().size()) { + throw new BadRequestException("订单明细数量不一致"); + } } + HashMap data = new HashMap<>(); BigDecimal returnAmount = BigDecimal.ZERO; BigDecimal packAMount = BigDecimal.ZERO; @@ -2850,7 +2966,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (remainNum.compareTo(BigDecimal.ZERO) <= 0) { returnAmount = orderDetail.getPriceAmount(); packAMount = orderDetail.getPackAmount(); - }else { + } else { currentDetailAMount = orderDetail.getPriceAmount() .divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP) .multiply(returnNum).setScale(2, RoundingMode.HALF_UP); @@ -3047,6 +3163,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { } else if ("cash".equals(payType)) { mpOrderDetailService.updateStatusByOrderIdAndIds(OrderStatusEnums.REFUNDING, OrderStatusEnums.REFUND, returnOrderDTO.getOrderId(), returnOrderDTO.getOrderDetails().stream().map(ReturnOrderDTO.OrderDetail::getId).collect(Collectors.toList())); + } else if (TableConstant.OrderInfo.PayType.CREDIT_BUYER.equalsVals(payType)) { + creditBuyerOrderService.refund(orderInfo.getCreditBuyerId(), Long.valueOf(orderInfo.getId())); } orderInfo.setStatus(TableConstant.OrderInfo.Status.CLOSED.getValue()); @@ -3057,30 +3175,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { .eq(TbOrderDetail::getStatus, TableConstant.OrderInfo.Status.CLOSED)); if (count == 0) { returnCoupon(orderInfo, true); - // 返还积分 - memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), - "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); + if (orderInfo.getMemberId() != null && orderInfo.getPointsNum() != null) { + // 返还积分 + memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), + "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); + } } -// String couponInfoList = orderInfo.getCouponInfoList(); -// if (StrUtil.isNotBlank(couponInfoList)) { -// OrderInfoCouponInfoDTO orderInfoCouponInfoDTO = JSONObject.parseObject(couponInfoList, OrderInfoCouponInfoDTO.class); -// if (orderInfoCouponInfoDTO.getProductCoupon() != null && !orderInfoCouponInfoDTO.getProductCoupon().isEmpty()) { -// int remainNum = 0; -// for (OrderInfoUserCouponVo item : orderInfoCouponInfoDTO.getProductCoupon()) { -// if (item.getFinalUseNum() > item.getReturnNum()) { -// remainNum = remainNum + (item.getFinalUseNum() - item.getReturnNum()); -// } -// } -// -// if (remainNum == 0) { -// returnCoupon(orderInfo, true); -// // 返还积分 -// memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), -// "用户退款订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); -// -// } -// } -// } } orderInfoMapper.updateById(orderInfo); // 打印退款小票 @@ -3135,7 +3235,105 @@ public class TbShopTableServiceImpl implements TbShopTableService { } + @Override + public TbCashierCart updatePrice(UpdatePriceDTO updatePriceDTO) { + TbCashierCart cashierCart = mpCashierCartService.selectByShopIdAndId(updatePriceDTO.getShopId(), updatePriceDTO.getCartId(), TableConstant.OrderInfo.Status.CREATE); + if (cashierCart == null) { + throw new BadRequestException("购物车商品不存在"); + } + + if (cashierCart.getIsMember() == 0) { + if (cashierCart.getSalePrice().subtract(updatePriceDTO.getSaleAmount()).compareTo(BigDecimal.ZERO) < 0) { + throw new BadRequestException("折扣金额不能超过单价"); + } + } else { + if (cashierCart.getMemberPrice().subtract(updatePriceDTO.getSaleAmount()).compareTo(BigDecimal.ZERO) < 0) { + throw new BadRequestException("折扣金额不能超过单价"); + } + } + + BigDecimal oldAmount = cashierCart.getTotalAmount(); + cashierCart.setDiscountSaleAmount(updatePriceDTO.getSaleAmount()); + cashierCart.resetTotalAmount(); + cashierCart.setUpdatedAt(DateUtil.current()); + cashierCart.setDiscountSaleNote(updatePriceDTO.getNote()); + cashierCart.setDiscountSaleAmount(updatePriceDTO.getSaleAmount()); + mpCashierCartService.updateById(cashierCart); + + // 更新订单和detail价格 + if (cashierCart.getOrderId() != null) { + mpOrderDetailService.updatePriceByCartId(cashierCart.getId(), updatePriceDTO.getSaleAmount(), cashierCart.getTotalAmount()); + mpOrderInfoService.incrAmount(cashierCart.getOrderId(), cashierCart.getTotalAmount().subtract(oldAmount)); + } + return cashierCart; + } + + @Override + public Object checkCoupon(ThirdCouponCheckDTO checkDTO) { + TbOrderInfo orderInfo = mpOrderInfoService.getById(checkDTO.getOrderId()); + if (orderInfo == null) { + throw new BadRequestException("订单信息不存在"); + } + + if (!TableConstant.OrderInfo.Status.UNPAID.equalsVals(orderInfo.getStatus())) { + throw new BadRequestException("订单不为待支付状态"); + } + + List cashierCarts = mpCashierCartService.selectByIds(checkDTO.getShopId(), checkDTO.getOrderId(), checkDTO.getCartId()); + if (cashierCarts.size() != checkDTO.getCartId().size()) { + throw new BadRequestException("含有不存在购物车"); + } + + CheckCouponDTO dto = new CheckCouponDTO(); + dto.setShopId(checkDTO.getShopId()); + dto.setCouponCode(checkDTO.getCode()); + dto.setNum(checkDTO.getNum()); + thirdPartyCouponService.checkCoupon(dto); + + BigDecimal incrAmount = BigDecimal.ZERO; + for (TbCashierCart item : cashierCarts) { + item.setIsThirdCoupon(1); + incrAmount = incrAmount.add(item.getTotalAmount()); + } + mpCashierCartService.updateBatchById(cashierCarts); + mpOrderDetailService.updateFieldByCartId(TbOrderDetail::getIsThirdCoupon, 1, checkDTO.getCartId()); + mpOrderInfoService.incrAmount(orderInfo.getId(), incrAmount.negate()); + + TbThirdPartyCouponRecord record = new TbThirdPartyCouponRecord(); + record.setOrderId(orderInfo.getId()); + record.setCode(checkDTO.getCode()); + record.setNum(1); + record.setState((byte) 1); + record.setPlat(TableConstant.ThirdPartyCoupon.Plat.MEI_TUAN.getValue()); + record.setCreateTime(DateUtil.date().toInstant()); + record.setCheckTime(DateUtil.date().toInstant()); + record.setShopId(checkDTO.getShopId()); + record.setCartIdList(JSONObject.toJSONString(checkDTO.getCartId())); + thirdPartyCouponRecordService.save(record); + return true; + } + @Override + public Object waitCall(WaitCallDTO waitCallDTO) { + ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(waitCallDTO.getShopId(), waitCallDTO.getTableId(), waitCallDTO.getUseType()); + List cashierCarts = mpCashierCartService.selectByShopEatTypeAndOrderId(shopEatTypeInfoDTO, + waitCallDTO.getMasterId(), waitCallDTO.getOrderId(), TableConstant.OrderInfo.Status.CREATE, TableConstant.OrderInfo.Status.RETURN, TableConstant.OrderInfo.Status.CLOSED); + if (cashierCarts.isEmpty()) { + throw new BadRequestException("购物车为空"); + } + ArrayList cartIds = new ArrayList<>(); + cashierCarts.forEach(item -> { + if (waitCallDTO.getOrderId() != null && item.getOrderId() != null && !item.getOrderId().equals(waitCallDTO.getOrderId())) { + throw new BadRequestException("订单id有误"); + } + cartIds.add(item.getId()); + }); + if (waitCallDTO.getOrderId() != null) { + mpOrderInfoService.updateFieldVal(waitCallDTO.getShopId(), waitCallDTO.getOrderId(), TbOrderInfo::getIsWaitCall, waitCallDTO.getIsWaitCall()); + } + mpCashierCartService.updateFieldValByIds(waitCallDTO.getShopId(), cartIds, TbCashierCart::getIsWaitCall, waitCallDTO.getIsWaitCall()); + return mpOrderDetailService.updateFieldByCartId(TbOrderDetail::getIsWaitCall, waitCallDTO.getIsWaitCall(), cartIds); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java index a45d6309..3d7da3f9 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java @@ -15,9 +15,11 @@ */ package cn.ysk.cashier.service.shop; +import cn.ysk.cashier.dto.BindingDto; import cn.ysk.cashier.pojo.shop.TbShopInfo; import cn.ysk.cashier.dto.shop.TbShopInfoDto; import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; +import com.alibaba.fastjson.JSONObject; import org.springframework.data.domain.Pageable; import java.util.Map; import java.util.List; @@ -32,6 +34,13 @@ import javax.servlet.http.HttpServletResponse; **/ public interface TbShopInfoService { + /** + * 绑定开票信息 + * @param bindingDto + * @return + */ + JSONObject binding(BindingDto bindingDto); + /** * 查询数据分页 * @param criteria 条件 @@ -39,6 +48,8 @@ public interface TbShopInfoService { */ Map queryAll(TbShopInfoQueryCriteria criteria); + List queryChildShop(TbShopInfoQueryCriteria criteria); + /** * 查询所有数据不分页 * @param criteria 条件参数 @@ -54,7 +65,6 @@ public interface TbShopInfoService { TbShopInfoDto findById(Integer id); TbShopInfo findByIdInfo(Integer id); - TbShopInfoDto finByAccount(String account); /** * 创建 * @param resources / diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java index ca10d873..c94ebc33 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java @@ -157,4 +157,16 @@ public interface TbShopTableService { Object bindQrcode(BindTableQrCodeDTO bindTableQrCodeDTO); + /** + * 修改购物车价格 + * @param updatePriceDTO 价格信息 + */ + TbCashierCart updatePrice(UpdatePriceDTO updatePriceDTO); + + /** + * 团购券核销 + */ + Object checkCoupon(ThirdCouponCheckDTO checkDTO); + + Object waitCall(WaitCallDTO waitCallDTO); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/utils/Utils.java b/eladmin-system/src/main/java/cn/ysk/cashier/utils/Utils.java index fbcc0f13..7a3ae219 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/utils/Utils.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/utils/Utils.java @@ -5,6 +5,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Component; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -12,10 +13,16 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; +@Component public class Utils { public static int retryCount = 5; + private static StringRedisTemplate redisTemplate; private static final Logger log = LoggerFactory.getLogger(Utils.class); + public Utils(StringRedisTemplate redisTemplate) { + Utils.redisTemplate = redisTemplate; + } + public static void catchErrNoReturn(Supplier supplier) { try { supplier.get(); @@ -116,4 +123,48 @@ public class Utils { } return result; } + + public static void checkLimit(String key, int maxRequests, long timeWindow) { + // 获取当前时间戳 + long now = System.currentTimeMillis(); + + // 获取之前的时间戳和计数从 Redis + String prevTimestamp = redisTemplate.opsForValue().get(key + ":timestamp"); + String prevCount = redisTemplate.opsForValue().get(key + ":count"); + + // 如果这是第一次请求,设置初始值 + if (prevTimestamp == null || prevCount == null) { + redisTemplate.opsForValue().set(key + ":timestamp", String.valueOf(now)); + redisTemplate.opsForValue().set(key + ":count", "1"); + redisTemplate.expire(key + ":timestamp", 5, TimeUnit.SECONDS); + redisTemplate.expire(key + ":count", 5, TimeUnit.SECONDS); + return; + } + + // 计算自上一次请求以来经过的时间 + long elapsed = now - Long.parseLong(prevTimestamp); + + // 如果时间窗口已经过去,重置计数 + if (elapsed > timeWindow) { + redisTemplate.opsForValue().set(key + ":timestamp", String.valueOf(now)); + redisTemplate.opsForValue().set(key + ":count", "1"); + redisTemplate.expire(key + ":timestamp", 5, TimeUnit.SECONDS); + redisTemplate.expire(key + ":count", 5, TimeUnit.SECONDS); + return; + } + + // 增加计数 + int count = Integer.parseInt(prevCount) + 1; + + // 如果计数超过最大值,返回 false + if (count > maxRequests) { + throw new BadRequestException("操作太快啦,请稍后再试"); + } + + // 更新计数和时间戳 + redisTemplate.opsForValue().set(key + ":count", String.valueOf(count)); + redisTemplate.opsForValue().set(key + ":timestamp", String.valueOf(now)); + redisTemplate.expire(key + ":timestamp", 5, TimeUnit.SECONDS); + redisTemplate.expire(key + ":count", 5, TimeUnit.SECONDS); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/ProductExtVO.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/ProductExtVO.java deleted file mode 100644 index 7aaa405e..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/ProductExtVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.ysk.cashier.vo; - -import lombok.Data; -import org.hibernate.annotations.Formula; - -import java.math.BigDecimal; -import java.math.BigInteger; - -/** - * @author lyf - */ -@Data -public class ProductExtVO { - private BigInteger productId; - - private String productName; - - private Object productNum; - private Object amount; - - public ProductExtVO(BigInteger productId, String productName, Object productNum, Object amount) { - this.productId = productId; - this.productName = productName; - this.productNum = productNum; - this.amount = amount; - } - - public ProductExtVO() { - } -} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/ProductGroupVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/ProductGroupVo.java new file mode 100644 index 00000000..ca49afc7 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/ProductGroupVo.java @@ -0,0 +1,34 @@ +package cn.ysk.cashier.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProductGroupVo { + + private Integer count; + //选几个 + private Integer number; + //类别 + private String title; + + //食物 + private List goods=new ArrayList<>(); + + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Food { + private Integer proId; + private String proName; + private Integer skuId; + private String skuName; + private BigDecimal price; + private String number; + private String unitName; + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java index 34e15dcf..cf704a98 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java @@ -28,6 +28,7 @@ public class TbProductNewVo { private String name; //售价 private String lowPrice; + private String type; //类型 单规格/多规格 private String typeEnum; //库存 @@ -53,24 +54,29 @@ public class TbProductNewVo { private Integer sort; public void setTypeEnum(String typeEnum) { - switch (typeEnum) { + switch (this.type) { case "normal": - this.typeEnum = "单规格"; + this.typeEnum = "普通商品"; break; - case "sku": - this.typeEnum = "多规格"; - break; - case "weight": + case "weigh": this.typeEnum = "称重商品"; - break; - case "currentPrice": - this.typeEnum = "时价商品"; - break; - case "group": - this.typeEnum = "套餐商品/团购卷"; - break; + return; + case "coupon": + this.typeEnum = "优惠券"; + return; + case "package": + this.typeEnum = "套餐商品"; + return; default: this.typeEnum = typeEnum; + return; + } + switch (typeEnum) { + case "normal": + this.typeEnum = this.typeEnum + ":单规格"; + break; + case "sku": + this.typeEnum = this.typeEnum + ":多规格"; break; } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java index d2ca7771..0e38ad25 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java @@ -25,27 +25,14 @@ public class TbProductVo { private Integer id; - - private String sourcePath; - - - private String merchantId; - - private String shopId; - private String name; - private String type; - - private BigDecimal packFee; - private BigDecimal lowPrice; - private Integer unitId; private String coverImg; @@ -56,154 +43,40 @@ public class TbProductVo { private Integer specId; - - private Integer brandId; - - private String shortTitle; - - private BigDecimal lowMemberPrice; - - - private String unitSnap; - - private String shareImg; - private JSONArray images; - - private String video; - - - private String videoCoverImg; - - private Integer sort; - - private Integer limitNumber; - - - private Integer productScore; - - private Integer status; - - private String failMsg; - - - private Integer isRecommend; - - private Integer isHot; - - private Integer isNew; - - private Integer isOnSale; - - private Integer isShow; - - + private String type; private String typeEnum; - private Integer isDel; - private Integer isStock; - private Integer isPauseSale; - - private Integer isFreeFreight; - - - private Long freightId; - - - private String strategyType; - - - private Integer strategyId; - - private Integer isVip; - - private Integer isDelete; - - - private String notice; - - private Long createdAt; - private Long updatedAt; - - private Double baseSalesNumber; - - //销量 private Double realSalesNumber; - //库存 + private Double stockNumber; - - private Integer salesNumber; - - private Integer thumbCount; - - - private Integer storeCount; - - - private Integer furnishMeal; - - - private Integer furnishExpress; - - - private Integer furnishDraw; - - - private Integer furnishVir; - - - private Integer isCombo; - - - private JSONArray groupSnap; - - - private Integer isShowCash; - - - private Integer isShowMall; - - - private Integer isNeedExamine; - - - private Integer showOnMallStatus; - - - private Long showOnMallTime; - - private String showOnMallErrorMsg; - - - private Integer enableLabel; - - private String taxConfigId; + private Integer groupType; private String unitName; @@ -227,9 +100,28 @@ public class TbProductVo { private Integer warnLine = 0; + private String showType; + + private BigDecimal weight; + + private Integer isTempPrice = 0; + + private Integer dayLimit = 0; + + private Integer singleOrderLimit = 0; + + private Integer singlePeopleLimit = 0; + + private String days; + + private String startTime; + + private String endTime; + private List conInfos; private TbPurchaseNotice notices=new TbPurchaseNotice(); private List groupCategoryId = new ArrayList<>(); private List tags = new ArrayList<>(); + private List proGroupVo; } diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml index debc3e04..415edd2e 100644 --- a/eladmin-system/src/main/resources/config/application.yml +++ b/eladmin-system/src/main/resources/config/application.yml @@ -107,3 +107,6 @@ gateway: client: backUrl: https://cashierclient.sxczgkj.cn/cashier-client/notify/notifyPay + +# php服务器地址 +phpServer: https://czgdoumei.sxczgkj.com/index.php/api diff --git a/eladmin-system/src/main/resources/mapper/TbThirdPartyCouponRecordMapper.xml b/eladmin-system/src/main/resources/mapper/TbThirdPartyCouponRecordMapper.xml new file mode 100644 index 00000000..539e2604 --- /dev/null +++ b/eladmin-system/src/main/resources/mapper/TbThirdPartyCouponRecordMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + id,order_id,state, + plat,code,create_time, + check_time,shop_id + + diff --git a/eladmin-system/src/main/resources/mapper/plus/TbCreditBuyerOrderMapper.xml b/eladmin-system/src/main/resources/mapper/plus/TbCreditBuyerOrderMapper.xml new file mode 100644 index 00000000..78d39762 --- /dev/null +++ b/eladmin-system/src/main/resources/mapper/plus/TbCreditBuyerOrderMapper.xml @@ -0,0 +1,72 @@ + + + + + + + + and t1.credit_buyer_id = #{creditBuyerId} + + and t1.order_id = #{orderId} + + + and t1.create_time >= str_to_date(concat(#{beginDate},' 00:00:00'), '%Y-%m-%d %H:%i:%s') + + + + + + and t1.status = #{status} + + + and t1.status in + + #{status} + + + + and t1.id = #{id} + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/eladmin-system/src/main/resources/mapper/plus/TbShopTableBookingMapper.xml b/eladmin-system/src/main/resources/mapper/plus/TbShopTableBookingMapper.xml new file mode 100644 index 00000000..d898e886 --- /dev/null +++ b/eladmin-system/src/main/resources/mapper/plus/TbShopTableBookingMapper.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file