Merge branch 'refs/heads/test' into dev
# Conflicts: # eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java # eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java # eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateCartDTO.java # eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java # eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java # eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java # eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java # eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java # eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java # eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java # eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java
This commit is contained in:
@@ -76,4 +76,6 @@ public interface CacheKey {
|
||||
String SONG_URL = "song:";
|
||||
|
||||
String VIPCODE = "VIPCODE:";
|
||||
|
||||
String INVOICE_SD_TYPE = "invoice:sd_type:";
|
||||
}
|
||||
|
||||
@@ -102,10 +102,13 @@ public class ListUtil {
|
||||
}
|
||||
|
||||
|
||||
public static<T> String listChangeString(List<T> listString){
|
||||
return listString.stream()
|
||||
.map(Object::toString)
|
||||
.collect(Collectors.joining(", "));
|
||||
public static <T> String listToJsonString(List<T> list) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
return objectMapper.writeValueAsString(list);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String mapToString(Map<String, String> map) {
|
||||
|
||||
@@ -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<Object> 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.<TbMerchantAccount>lambdaQuery()
|
||||
// .eq(TbMerchantAccount::getAccount, shopStaff.getAccount()));
|
||||
// Integer accountId = merchantAccount.getId();
|
||||
// Integer staffId = shopStaff.getId();
|
||||
// List<TbToken> onlineUserList = tbTokenRepository.findListByAccountIdAndStaffId(accountId, staffId);
|
||||
shopStaff.setPassword(null);
|
||||
return ResponseEntity.ok(new HashMap<String, Object>(){{
|
||||
put("shopInfo", shopInfo);
|
||||
put("shopStaff", shopStaff);
|
||||
}});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序登录
|
||||
*
|
||||
|
||||
@@ -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 获取鉴权信息
|
||||
*
|
||||
|
||||
@@ -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 /
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -30,6 +30,7 @@ public class SuppFlow implements Serializable {
|
||||
@Data
|
||||
public static class ConInfos{
|
||||
private Integer conInfoId;
|
||||
private String name;
|
||||
|
||||
private String unit;
|
||||
|
||||
|
||||
@@ -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<TbConsInfo, Integer>
|
||||
" where conPro.con_info_id = :conInfoId " +
|
||||
" group by conPro.product_id ",nativeQuery = true)
|
||||
List<Map<Integer, Object>> 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<TbConsInfo> searchConsInfoByShopId(Integer shopId);
|
||||
|
||||
@Modifying
|
||||
@Query(value = "delete FROM tb_prosku_con conPro where conPro.shop_id = :shopId ",nativeQuery = true)
|
||||
void clearShopCons(Integer shopId);
|
||||
}
|
||||
@@ -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, Integer>
|
||||
|
||||
TbConsType findByConTypeCode(String conTypeCode);
|
||||
|
||||
@Query("SELECT c FROM TbConsType c WHERE c.shopId = :shopId")
|
||||
List<TbConsType> 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);
|
||||
}
|
||||
|
||||
@@ -30,4 +30,11 @@ public interface TbProskuConRepository extends JpaRepository<TbProskuCon, Intege
|
||||
|
||||
List<TbProskuCon> searchAllByProductId(Integer productId);
|
||||
|
||||
@Query(value = "select * from tb_prosku_con where shop_id=?1 ",nativeQuery = true)
|
||||
List<TbProskuCon> searchConsProByShopId(Integer shopId);
|
||||
|
||||
@Modifying
|
||||
@Query(value = "delete from tb_prosku_con where shop_id = :shopId",nativeQuery = true)
|
||||
void clearShopConPro(Integer shopId);
|
||||
|
||||
}
|
||||
@@ -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()));
|
||||
|
||||
@@ -67,7 +67,6 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
||||
private final TbProductStockOperateRepository tbProductStockOperateRepository;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(TbConsInfoQueryCriteria criteria, Pageable pageable) {
|
||||
Page<TbConsInfo> page = tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
@@ -77,7 +76,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
||||
@Override
|
||||
public Map<String, Object> 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<TbConsInfo> resources){
|
||||
public TbConsInfoDto create(List<TbConsInfo> 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
|
||||
|
||||
@@ -36,7 +36,6 @@ public class TbShopShareController {
|
||||
private TbShopShareRecordService tbShopShareRecordService;
|
||||
|
||||
@PostMapping("byShare")
|
||||
@AnonymousPostMapping
|
||||
@ApiOperation("分页查询")
|
||||
public ResponseEntity<Object> selectAllByShare(@RequestBody TbShopShareRecordQueryCriteria criteria) {
|
||||
return new ResponseEntity<>(tbShopShareRecordService.selectAllByShare(criteria), HttpStatus.OK);
|
||||
|
||||
@@ -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<Object> selectAll(TbShopSyncInfoQueryCriteria criteria) {
|
||||
return new ResponseEntity<>(tbShopSyncInfoService.queryByShopId(criteria), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/sync")
|
||||
@ApiOperation("同步")
|
||||
public ResponseEntity<Object> 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<Object> 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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<Map<String, Object>> getState(@RequestParam Integer shopId) {
|
||||
return ResponseEntity.ok(thirdPartyCouponService.getState(shopId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取美团绑定链接
|
||||
* @return 美团绑定链接
|
||||
*/
|
||||
@GetMapping("bindUrl")
|
||||
public ResponseEntity<String> getBindUrl(@RequestParam Integer shopId) {
|
||||
return ResponseEntity.ok(thirdPartyCouponService.getBindUrl(shopId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 解绑美团商家
|
||||
* @return 美团解绑链接
|
||||
*/
|
||||
@GetMapping("unBindUrl")
|
||||
public ResponseEntity<String> getUnBindUrl(@RequestParam Integer shopId) {
|
||||
return ResponseEntity.ok(thirdPartyCouponService.getUnBindUrl(shopId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取门店客核销券
|
||||
* @return 所有券
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public ResponseEntity<Map<String, Object>> getActivateCoupon(@RequestParam Integer shopId, @RequestParam String code) {
|
||||
return ResponseEntity.ok(thirdPartyCouponService.getActivateCoupon(shopId, code));
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销券
|
||||
*/
|
||||
@PostMapping
|
||||
public ResponseEntity<Map<String, Object>> checkCoupon(@RequestBody CheckCouponDTO checkCouponDTO) {
|
||||
return ResponseEntity.ok(thirdPartyCouponService.checkCoupon(checkCouponDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤销券核销
|
||||
*/
|
||||
@DeleteMapping("revoke")
|
||||
public ResponseEntity<Map<String, Object>> revokeCoupon(@RequestBody CheckCouponDTO checkCouponDTO) {
|
||||
return ResponseEntity.ok(thirdPartyCouponService.revokeCoupon(checkCouponDTO));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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<String, Object> params) {
|
||||
Map<String, Object> 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<String, Object> 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<TbShopArea> list = tbShopTableBookingService.findShopAreaList(shopId);
|
||||
return ResponseEntity.ok().body(list);
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
@ApiOperation("获取台桌列表")
|
||||
public ResponseEntity list(@RequestParam Map<String, Object> params) {
|
||||
List<ShopTableBookingDTO> list = tbShopTableBookingService.findShopTableList(params);
|
||||
return ResponseEntity.ok().body(list);
|
||||
}
|
||||
|
||||
@PostMapping("summary")
|
||||
@ApiOperation("根据电话号码统计历史预订信息")
|
||||
public ResponseEntity summary(@RequestBody Map<String, Object> params) {
|
||||
MapProxy proxy = MapUtil.createProxy(params);
|
||||
Integer shopId = proxy.getInt("shopId");
|
||||
String[] phoneNos = Convert.toStrArray(proxy.get("phoneNos"));
|
||||
Map<String, Object> data = tbShopTableBookingService.summary(shopId, phoneNos);
|
||||
return ResponseEntity.ok().body(data);
|
||||
}
|
||||
}
|
||||
@@ -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<String, Object> params){
|
||||
Map<String, Object> 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<String, Object> params) {
|
||||
Map<String, Object> data = tbCreditBuyerService.repayment(params);
|
||||
return ResponseEntity.ok().body(data);
|
||||
}
|
||||
}
|
||||
@@ -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<String, Object> params) {
|
||||
Map<String, Object> 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<String, Object> params) {
|
||||
Map<String, Object> data = tbCreditBuyerOrderService.summary(params);
|
||||
return ResponseEntity.ok().body(data);
|
||||
}
|
||||
}
|
||||
@@ -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<String, Object> params){
|
||||
Map<String, Object> page = tbCreditPaymentRecordService.page(params);
|
||||
return ResponseEntity.ok().body(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<TbCashierCart> addTemporaryDishes(@Valid @RequestBody AddTemporaryDishesDTO temporaryDishesDTO) {
|
||||
return ResponseEntity.ok(tbShopTableService.addTemporaryDishes(temporaryDishesDTO));
|
||||
}
|
||||
|
||||
@PutMapping("/updatePrice")
|
||||
public ResponseEntity<TbCashierCart> 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<Object> createOrder(@RequestBody CreateOrderDTO createOrderDTO) {
|
||||
public ResponseEntity<Object> 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<Object> checkCoupon(@Validated @RequestBody ThirdCouponCheckDTO checkDTO) {
|
||||
return ResponseEntity.ok(tbShopTableService.checkCoupon(checkDTO));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
@GetMapping("/test")
|
||||
public void test(
|
||||
|
||||
@@ -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<Object> binding(@Validated @RequestBody BindingDto bindingDto){
|
||||
return new ResponseEntity<>(shopInfoService.binding(bindingDto), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("subInvoicing")
|
||||
@ApiOperation("提交开票")
|
||||
public ResponseEntity<Object> subInvoicing(@RequestBody Map<String, Object> params){
|
||||
return new ResponseEntity<>(bindService.subInvoicing(params), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("industry")
|
||||
@ApiOperation("获取项目分类")
|
||||
@AnonymousPostMapping("industry")
|
||||
public ResponseEntity<Object> industry(@RequestBody BindingDto bindingDto){
|
||||
return new ResponseEntity<>(bindService.industry(bindingDto), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("digitalInvoice")
|
||||
@ApiOperation("数电发票类型")
|
||||
@AnonymousPostMapping("digitalInvoice")
|
||||
public ResponseEntity<Object> digitalInvoice(){
|
||||
return new ResponseEntity<>(bindService.digitalInvoice(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("storeSe")
|
||||
@ApiOperation("计算税额")
|
||||
@AnonymousPostMapping("storeSe")
|
||||
public ResponseEntity<Object> storeSe(@RequestBody Map<String, Object> params){
|
||||
return new ResponseEntity<>(bindService.storeSe(params), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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<Object> 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<String, Object> authInfo = new HashMap<String, Object>(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<Object> queryChildShop(TbShopInfoQueryCriteria criteria){
|
||||
return new ResponseEntity<>(tbShopInfoService.queryChildShop(criteria),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询/shop/list")
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/** 行业 */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Integer> groupProductIdList;
|
||||
|
||||
// 用餐类型
|
||||
@NotBlank
|
||||
private String useType;
|
||||
|
||||
@@ -29,5 +29,6 @@ public class CreateOrderDTO {
|
||||
private List<UserCouponInfoDTO> userCouponInfos = new ArrayList<>();
|
||||
// 使用的积分抵扣数量
|
||||
private Integer pointsNum;
|
||||
private Integer isWaitCall;
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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<Integer> cartId;
|
||||
}
|
||||
@@ -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<Integer> groupProductIdList;
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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<TbShopSyncInfo> {
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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<TbCreditBuyer> {
|
||||
|
||||
}
|
||||
@@ -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<TbCreditBuyerOrder> {
|
||||
|
||||
List<CreditBuyerOrderDTO> getList(Map<String, Object> params);
|
||||
|
||||
long getCount(Map<String, Object> params);
|
||||
|
||||
BigDecimal getSumPayAmount(Map<String, Object> params);
|
||||
|
||||
BigDecimal getSumPaidAmount(Map<String, Object> params);
|
||||
|
||||
BigDecimal getSumUnpaidAmount(Map<String, Object> params);
|
||||
|
||||
CreditBuyerOrderDTO getOne(Map<String, Object> params);
|
||||
|
||||
}
|
||||
@@ -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<TbCreditPaymentRecord> {
|
||||
|
||||
}
|
||||
@@ -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<TbShopSyncInfo> {
|
||||
|
||||
}
|
||||
|
||||
@@ -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<TbShopTableBooking> {
|
||||
|
||||
List<Map<String, Object>> summaryByPhoneNos(@Param("shopId") Integer shopId, @Param("phoneNoList") List<String> phoneNoList);
|
||||
|
||||
}
|
||||
@@ -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<TbThirdPartyCouponRecord> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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<TbCashierCart> {
|
||||
/**
|
||||
* 根据店就餐模式查询购物车
|
||||
* @param shopEatTypeInfoDTO 就餐模式
|
||||
* @param masterId 取餐码
|
||||
* @param statuses 状态 为空默认查询 create return
|
||||
* @return 购物车信息
|
||||
*/
|
||||
List<TbCashierCart> selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId);
|
||||
List<TbCashierCart> selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, TableConstant.OrderInfo.Status... statuses);
|
||||
|
||||
|
||||
List<TbCashierCart> selectByShopEatTypeAndOrderId(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer orderId, TableConstant.OrderInfo.Status... statuses);
|
||||
|
||||
/**
|
||||
* 根据订单id和状态获取购物车数据
|
||||
@@ -73,5 +80,31 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
|
||||
|
||||
|
||||
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<TbCashierCart> selectByIds(Integer shopId, Integer orderId, List<Integer> ids, TableConstant.OrderInfo.Status... statuses);
|
||||
|
||||
boolean updateFieldValByIds(Integer shopId, ArrayList<Integer> cartIds, SFunction<TbCashierCart, ?> column, Object val);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<TbOrderDetail> {
|
||||
* @param isMember 会员id
|
||||
*/
|
||||
boolean updateMemberByOrderId(Integer orderId, boolean isMember);
|
||||
|
||||
boolean updateFieldByCartId(SFunction<TbOrderDetail, ?> field, Object val, List<Integer> cartIds);
|
||||
}
|
||||
|
||||
|
||||
@@ -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> {
|
||||
*/
|
||||
TbOrderInfo selectOrderByIdAndState(Integer orderId, TableConstant.OrderInfo.Status status);
|
||||
|
||||
boolean incrAmount(Integer orderId, BigDecimal subtract);
|
||||
|
||||
|
||||
boolean updateFieldVal(Integer shopId, Integer orderId, SFunction<TbOrderInfo, ?> column, Object val);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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<TbCreditBuyerOrder> {
|
||||
|
||||
Map<String, Object> page(Map<String, Object> params);
|
||||
Map<String, Object> summary(Map<String, Object> 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);
|
||||
|
||||
}
|
||||
@@ -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<TbCreditBuyer> {
|
||||
|
||||
Map<String, Object> page(Map<String, Object> params);
|
||||
|
||||
boolean save(TbCreditBuyer entity);
|
||||
|
||||
boolean update(TbCreditBuyer dto);
|
||||
|
||||
void delete(String id);
|
||||
|
||||
TbCreditBuyer getById(String id);
|
||||
|
||||
Map<String,Object> repayment(Map<String, Object> params);
|
||||
|
||||
|
||||
}
|
||||
@@ -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<TbCreditPaymentRecord> {
|
||||
|
||||
Map<String, Object> page(Map<String, Object> params);
|
||||
|
||||
}
|
||||
@@ -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> {
|
||||
|
||||
TbShopSyncInfo queryByShopId(TbShopSyncInfoQueryCriteria criteria);
|
||||
void sync(TbShopSyncInfo tbShopSyncInfo);
|
||||
void clear(TbShopSyncInfo tbShopSyncInfo);
|
||||
|
||||
}
|
||||
|
||||
@@ -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<TbShopTableBooking> {
|
||||
|
||||
Map<String, Object> page(Map<String, Object> 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<TbShopArea> findShopAreaList(Integer shopId);
|
||||
|
||||
List<ShopTableBookingDTO> findShopTableList(Map<String, Object> params);
|
||||
|
||||
Map<String, Object> summary(Integer shopId,String[] phoneNos);
|
||||
|
||||
void batchTimeout();
|
||||
|
||||
void autoCancel();
|
||||
}
|
||||
@@ -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<TbThirdPartyCouponRecord> {
|
||||
|
||||
}
|
||||
@@ -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<TbCashierCartMapper, T
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbCashierCart> selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId) {
|
||||
public List<TbCashierCart> selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, TableConstant.OrderInfo.Status... statuses) {
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.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<TbCashierCart> selectByShopEatTypeAndOrderId(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer orderId, TableConstant.OrderInfo.Status... statuses) {
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.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<TbCashierCartMapper, T
|
||||
}
|
||||
return queryChainWrapper.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbCashierCart selectOneCartByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer productId, Integer skuId, boolean isGift, boolean isTemp) {
|
||||
LambdaQueryWrapper<TbCashierCart> query = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.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<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.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<TbCashierCart> selectByIds(Integer shopId, Integer orderId, List<Integer> ids, TableConstant.OrderInfo.Status... statuses) {
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.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<Integer> cartIds, SFunction<TbCashierCart, ?> column, Object val) {
|
||||
return update(new LambdaUpdateWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, shopId)
|
||||
.in(TbCashierCart::getId, cartIds)
|
||||
.set(column, val));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<TbOrderDetailMapper, T
|
||||
.eq(TbOrderDetail::getOrderId, orderId)
|
||||
.set(TbOrderDetail::getIsMember, isMember ? 1 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateFieldByCartId(SFunction<TbOrderDetail, ?> field, Object val, List<Integer> cartIds) {
|
||||
LambdaUpdateWrapper<TbOrderDetail> query = new LambdaUpdateWrapper<TbOrderDetail>()
|
||||
.set(field, val);
|
||||
if (!cartIds.isEmpty()) {
|
||||
query.in(TbOrderDetail::getCartId, cartIds);
|
||||
}
|
||||
return update(query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<TbOrderInfoMapper, TbOrd
|
||||
.eq(TbOrderInfo::getId, orderId)
|
||||
.eq(TbOrderInfo::getStatus, status.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrAmount(Integer orderId, BigDecimal subtract) {
|
||||
return update(new LambdaUpdateWrapper<TbOrderInfo>()
|
||||
.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<TbOrderInfo, ?> column, Object val) {
|
||||
return update(new LambdaUpdateWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getShopId, shopId)
|
||||
.eq(TbOrderInfo::getId, orderId)
|
||||
.set(column, val));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<TbCreditBuyerOrderMapper, TbCreditBuyerOrder> implements TbCreditBuyerOrderService {
|
||||
|
||||
@Resource
|
||||
private TbCreditBuyerService tbCreditBuyerService;
|
||||
@Resource
|
||||
private TbCreditBuyerMapper tbCreditBuyerMapper;
|
||||
@Resource
|
||||
private TbCreditPaymentRecordMapper tbCreditPaymentRecordMapper;
|
||||
@Resource
|
||||
private MpOrderInfoService mpOrderInfoService;
|
||||
|
||||
private LambdaQueryWrapper<TbCreditBuyerOrder> getWrapper(Map<String, Object> params) {
|
||||
MapProxy mapProxy = MapProxy.create(params);
|
||||
String beginDate = mapProxy.getStr("beginDate");
|
||||
String endDate = mapProxy.getStr("endDate");
|
||||
TbCreditBuyerOrder param = BeanUtil.toBean(params, TbCreditBuyerOrder.class);
|
||||
LambdaQueryWrapper<TbCreditBuyerOrder> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.orderByDesc(TbCreditBuyerOrder::getOrderId);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> page(Map<String, Object> params) {
|
||||
MapProxy mapProxy = MapProxy.create(params);
|
||||
int pageNum = mapProxy.getInt("page", 1);
|
||||
int pageSize = mapProxy.getInt("size", 10);
|
||||
Page<PadProductCategoryDTO> page = new Page<>(pageNum, pageSize);
|
||||
page.addOrder(OrderItem.desc("order_id"));
|
||||
params.put("page", page);
|
||||
List<CreditBuyerOrderDTO> list = baseMapper.getList(params);
|
||||
return PageUtil.toPlusPage(list, Convert.toInt(page.getTotal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> summary(Map<String, Object> params) {
|
||||
long count = baseMapper.getCount(params);
|
||||
Map<String, Object> 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<String, Object> 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<String, Object> 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;
|
||||
}
|
||||
}
|
||||
@@ -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<TbCreditBuyerMapper, TbCreditBuyer> implements TbCreditBuyerService {
|
||||
|
||||
@Resource
|
||||
private TbCreditBuyerOrderMapper tbCreditBuyerOrderMapper;
|
||||
|
||||
@Resource
|
||||
private TbCreditPaymentRecordMapper tbCreditPaymentRecordMapper;
|
||||
|
||||
private LambdaQueryWrapper<TbCreditBuyer> getWrapper(Map<String, Object> params) {
|
||||
MapProxy mapProxy = MapProxy.create(params);
|
||||
String keywords = mapProxy.getStr("keywords");
|
||||
String repaymentStatus = mapProxy.getStr("repaymentStatus");
|
||||
TbCreditBuyer param = BeanUtil.toBean(params, TbCreditBuyer.class);
|
||||
|
||||
LambdaQueryWrapper<TbCreditBuyer> 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<String, Object> page(Map<String, Object> params) {
|
||||
MapProxy mapProxy = MapProxy.create(params);
|
||||
int pageNum = mapProxy.getInt("page", 1);
|
||||
int pageSize = mapProxy.getInt("size", 10);
|
||||
LambdaQueryWrapper<TbCreditBuyer> wrapper = getWrapper(params);
|
||||
Page<TbCreditBuyer> 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<String, Object> params = new HashMap<>();
|
||||
params.put("id", dto.getId());
|
||||
params.put("shopId", dto.getShopId());
|
||||
LambdaQueryWrapper<TbCreditBuyer> 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.<TbCreditBuyer>lambdaUpdate().set(TbCreditBuyer::getDelFlag, 1).eq(TbCreditBuyer::getId, id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbCreditBuyer getById(String id) {
|
||||
LambdaQueryWrapper<TbCreditBuyer> 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<String, Object> repayment(Map<String, Object> 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<String, Object> 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<String, Object> where = new HashMap<>();
|
||||
where.put("creditBuyerId", param.getId());
|
||||
where.put("statusList", Arrays.asList("unpaid", "partial"));
|
||||
List<CreditBuyerOrderDTO> list = tbCreditBuyerOrderMapper.getList(where);
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw new BadRequestException("没有需要还款的订单");
|
||||
}
|
||||
int repaymentCount = 0;
|
||||
List<CreditBuyerOrderDTO> 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.<TbCreditBuyerOrder>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.<TbCreditBuyerOrder>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<String, Object> 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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<TbCreditPaymentRecordMapper, TbCreditPaymentRecord> implements TbCreditPaymentRecordService {
|
||||
|
||||
private LambdaQueryWrapper<TbCreditPaymentRecord> getWrapper(Map<String, Object> params) {
|
||||
TbCreditPaymentRecord param = BeanUtil.toBean(params, TbCreditPaymentRecord.class);
|
||||
LambdaQueryWrapper<TbCreditPaymentRecord> 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<String, Object> page(Map<String, Object> params) {
|
||||
MapProxy mapProxy = MapProxy.create(params);
|
||||
int pageNum = mapProxy.getInt("page", 1);
|
||||
int pageSize = mapProxy.getInt("size", 10);
|
||||
LambdaQueryWrapper<TbCreditPaymentRecord> wrapper = getWrapper(params);
|
||||
wrapper.orderByDesc(TbCreditPaymentRecord::getId);
|
||||
Page<TbCreditPaymentRecord> page = super.page(new Page<>(pageNum, pageSize), wrapper);
|
||||
return PageUtil.toPlusPage(page.getRecords(), Convert.toInt(page.getTotal()));
|
||||
}
|
||||
}
|
||||
@@ -250,7 +250,7 @@ public class TbPointsExchangeRecordServiceImpl extends ServiceImpl<TbPointsExcha
|
||||
.set(TbPointsExchangeRecord::getCancelOrRefundTime, new Date())
|
||||
.set(TbPointsExchangeRecord::getCancelOrRefundReason, "超时未支付,系统自动取消订单")
|
||||
.eq(TbPointsExchangeRecord::getStatus, "unpaid")
|
||||
.last("and TIMESTAMPDIFF(MINUTE, create_time, NOW()) >= 5"));
|
||||
.last("and TIMESTAMPDIFF(MINUTE, NOW(), create_time) >= 5"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<TbShopSyncInfoMapper, TbShopSyncInfo> 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<TbShopSyncInfo> 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<Integer, Integer> units;
|
||||
Map<Integer, Integer> specs;
|
||||
Map<Integer, Integer> cateGorys;
|
||||
Map<Integer, Integer> groups;
|
||||
Map<Integer, Integer> pros = new HashMap<>();
|
||||
Map<Integer, Integer> skus = new HashMap<>();
|
||||
Map<Integer, Integer> conTypes;
|
||||
Map<Integer, Integer> consInfos = new HashMap<>();
|
||||
Map<Integer, Integer> consPros = new HashMap<>();
|
||||
Integer skuResults = 0;
|
||||
TbShopSyncInfoServiceImpl self = applicationContext.getBean(TbShopSyncInfoServiceImpl.class);
|
||||
|
||||
try {
|
||||
List<CompletableFuture<?>> futures = new ArrayList<>();
|
||||
List<CompletableFuture<?>> futures2 = new ArrayList<>();
|
||||
if (tbShopSyncInfo.getProduct() != null && tbShopSyncInfo.getProduct() > 0) {
|
||||
CompletableFuture<Map<Integer, Integer>> futureUnit = self.syncUnit(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId());
|
||||
CompletableFuture<Map<Integer, Integer>> futureSpec = self.syncSpec(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId());
|
||||
CompletableFuture<Map<Integer, Integer>> 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<Map<Integer, Integer>> futurePros = self.syncProduct(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId(), units, specs, cateGorys);
|
||||
pros = futurePros.get();
|
||||
tbShopSyncInfo.setProduct(pros.size());
|
||||
|
||||
self.syncGroupPackage(tbShopSyncInfo.getPointShopId(), pros, skus);
|
||||
CompletableFuture<Map<Integer, Integer>> futureGroup = self.syncGroup(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId(), pros);
|
||||
CompletableFuture<Map<Integer, Integer>> futureSkus = self.syncSku(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId(), pros);
|
||||
CompletableFuture<Integer> 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<Map<Integer, Integer>> futureUnit = self.syncUnit(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId());
|
||||
units = futureUnit.get();
|
||||
tbShopSyncInfo.setProUnit(units.size());
|
||||
}
|
||||
if (tbShopSyncInfo.getProCategory() != null && tbShopSyncInfo.getProCategory() > 0) {
|
||||
CompletableFuture<Map<Integer, Integer>> futureCate = self.syncCategory(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId());
|
||||
cateGorys = futureCate.get();
|
||||
tbShopSyncInfo.setProCategory(cateGorys.size());
|
||||
}
|
||||
if (tbShopSyncInfo.getProSpec() != null && tbShopSyncInfo.getProSpec() > 0) {
|
||||
CompletableFuture<Map<Integer, Integer>> futureSpec = self.syncSpec(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId());
|
||||
specs = futureSpec.get();
|
||||
tbShopSyncInfo.setProSpec(specs.size());
|
||||
}
|
||||
}
|
||||
|
||||
if (tbShopSyncInfo.getConsInfo() != null && tbShopSyncInfo.getConsInfo() > 0) {
|
||||
CompletableFuture<Map<Integer, Integer>> futureConTypes = self.syncConsType(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId());
|
||||
conTypes = futureConTypes.get();
|
||||
tbShopSyncInfo.setConsType(conTypes.size());
|
||||
|
||||
CompletableFuture<Map<Integer, Integer>> futureConsInfos = self.syncCons(tbShopSyncInfo.getSourceShopId(), tbShopSyncInfo.getPointShopId(), conTypes);
|
||||
consInfos = futureConsInfos.get();
|
||||
tbShopSyncInfo.setConsInfo(consInfos.size());
|
||||
} else if (tbShopSyncInfo.getConsType() != null && tbShopSyncInfo.getConsType() > 0) {
|
||||
CompletableFuture<Map<Integer, Integer>> 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<Map<Integer, Integer>> 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<TbProduct> products = productRepository.selectByShopId(tbShopSyncInfo.getPointShopId().toString());
|
||||
List<Integer> 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<TbProskuCon> tbProskuCons = proSkuConRepository.searchConsProByShopId(tbShopSyncInfo.getPointShopId());
|
||||
List<Integer> proCons = tbProskuCons.stream().map(TbProskuCon::getId).collect(Collectors.toList());
|
||||
proSkuConRepository.deleteAllByIdInBatch(proCons);
|
||||
|
||||
proSkuConRepository.clearShopConPro(tbShopSyncInfo.getPointShopId());
|
||||
QueryWrapper<TbShopSyncInfo> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("point_shop_id", tbShopSyncInfo.getPointShopId());
|
||||
tbShopSyncInfomapper.delete(wrapper);
|
||||
}
|
||||
|
||||
//单位
|
||||
@Async
|
||||
public CompletableFuture<Map<Integer, Integer>> syncUnit(Integer sourceShopId, Integer pointShopId) {
|
||||
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
|
||||
Map<Integer, Integer> 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<Map<Integer, Integer>> syncSpec(Integer sourceShopId, Integer pointShopId) {
|
||||
log.info("规格同步 "+System.currentTimeMillis());
|
||||
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
|
||||
Map<Integer, Integer> 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<Map<Integer, Integer>> syncCategory(Integer sourceShopId, Integer pointShopId) {
|
||||
log.info("分类同步 "+System.currentTimeMillis());
|
||||
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
|
||||
Map<Integer, Integer> categoryMap = new HashMap<>();
|
||||
List<TbShopCategory> tbShopCategories = categoryRepository.searchCategoryByShopId(sourceShopId.toString());
|
||||
List<Integer> 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<TbShopCategory> 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<Map<Integer, Integer>> syncProduct(Integer sourceShopId, Integer pointShopId, Map<Integer, Integer> units,
|
||||
Map<Integer, Integer> specs, Map<Integer, Integer> cateGorys) {
|
||||
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
|
||||
String cateGory = "";
|
||||
if(CollectionUtil.isNotEmpty(cateGorys)){
|
||||
cateGory = cateGorys.keySet().stream().findFirst().get().toString();
|
||||
}
|
||||
|
||||
Map<Integer, Integer> proMap = new HashMap<>();
|
||||
List<TbProduct> 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<Map<Integer, Integer>> syncGroup(Integer sourceShopId, Integer pointShopId, Map<Integer, Integer> pros) {
|
||||
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
|
||||
Map<Integer, Integer> 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<Integer, Integer> pros, Map<Integer, Integer> 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<Map<Integer, Integer>> syncSku(Integer sourceShopId, Integer pointShopId, Map<Integer, Integer> pros) {
|
||||
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
|
||||
Map<Integer, Integer> 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<Integer> syncSkuResult(Map<Integer, Integer> pros) {
|
||||
CompletableFuture<Integer> future = new CompletableFuture<>();
|
||||
List<TbProductSkuResult> 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<Map<Integer, Integer>> syncConsType(Integer sourceShopId, Integer pointShopId) {
|
||||
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
|
||||
Map<Integer, Integer> consTypeMap = new HashMap<>();
|
||||
|
||||
List<TbConsType> 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<Map<Integer, Integer>> syncCons(Integer sourceShopId, Integer pointShopId, Map<Integer, Integer> conTypes) {
|
||||
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
|
||||
Map<Integer, Integer> consMap = new HashMap<>();
|
||||
List<TbConsInfo> 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<Map<Integer, Integer>> syncConsPro(Integer sourceShopId, Integer pointShopId, Map<Integer, Integer> consMap, Map<Integer, Integer> proMap, Map<Integer, Integer> skuMap) {
|
||||
CompletableFuture<Map<Integer, Integer>> future = new CompletableFuture<>();
|
||||
Map<Integer, Integer> 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<Integer, Integer> 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 "[]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<TbShopTableBookingMapper, TbShopTableBooking> implements TbShopTableBookingService {
|
||||
|
||||
private static final Map<String, String> BOOKING_TYPE = MapUtil.builder("lunch", "午餐")
|
||||
.put("dinner", "晚餐")
|
||||
.build();
|
||||
|
||||
@Resource
|
||||
private TbShopInfoRepository tbShopInfoRepository;
|
||||
|
||||
@Resource
|
||||
private MpShopTableMapper mpShopTableMapper;
|
||||
|
||||
@Resource
|
||||
private MpShopAreaMapper mpShopAreaMapper;
|
||||
|
||||
private LambdaQueryWrapper<TbShopTableBooking> getWrapper(Map<String, Object> params) {
|
||||
MapProxy mapProxy = MapProxy.create(params);
|
||||
String keywords = mapProxy.getStr("keywords");
|
||||
TbShopTableBooking param = BeanUtil.toBean(params, TbShopTableBooking.class);
|
||||
|
||||
LambdaQueryWrapper<TbShopTableBooking> 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<String, Object> page(Map<String, Object> params) {
|
||||
MapProxy mapProxy = MapProxy.create(params);
|
||||
int pageNum = mapProxy.getInt("page", 1);
|
||||
int pageSize = mapProxy.getInt("size", 10);
|
||||
LambdaQueryWrapper<TbShopTableBooking> wrapper = getWrapper(params);
|
||||
|
||||
Page<TbShopTableBooking> 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.<TbShopTableBooking>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.<TbShopTableBooking>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.<TbShopTableBooking>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<TbShopArea> findShopAreaList(Integer shopId) {
|
||||
List<TbShopTable> tableList = mpShopTableMapper.selectList(Wrappers.<TbShopTable>lambdaQuery().eq(TbShopTable::getShopId, shopId).eq(TbShopTable::getIsPredate, 1));
|
||||
if (CollUtil.isEmpty(tableList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Set<Integer> areaId = tableList.stream().map(TbShopTable::getAreaId).collect(Collectors.toSet());
|
||||
List<TbShopArea> areaList = mpShopAreaMapper.selectList(Wrappers.<TbShopArea>lambdaQuery().in(TbShopArea::getId, areaId));
|
||||
if (CollUtil.isEmpty(areaList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return areaList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopTableBookingDTO> findShopTableList(Map<String, Object> params) {
|
||||
MapProxy mapProxy = MapProxy.create(params);
|
||||
Integer areaId = mapProxy.getInt("areaId");
|
||||
TbShopTableBooking param = BeanUtil.toBean(params, TbShopTableBooking.class);
|
||||
List<TbShopTable> tableList = mpShopTableMapper.selectList(
|
||||
Wrappers.<TbShopTable>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<ShopTableBookingDTO> result = BeanUtil.copyToList(tableList, ShopTableBookingDTO.class);
|
||||
Date bookingDate = param.getBookingDate();
|
||||
String bookingType = param.getBookingType();
|
||||
LambdaQueryWrapper<TbShopTableBooking> 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<TbShopTableBooking> 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<String, Object> summary(Integer shopId, String[] phoneNos) {
|
||||
List<String> phoneNoList = Arrays.asList(phoneNos).stream().distinct().collect(Collectors.toList());
|
||||
List<List<String>> splits = CollUtil.split(phoneNoList, 10);
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (List<String> split : splits) {
|
||||
List<Map<String, Object>> subList = baseMapper.summaryByPhoneNos(shopId, split);
|
||||
list.addAll(subList);
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>(phoneNoList.size());
|
||||
for (String phoneNo : phoneNos) {
|
||||
Map<String, Object> fillData = new HashMap<>(3);
|
||||
fillData.put("consumeOrders", 0);
|
||||
fillData.put("cancelOrders", 0);
|
||||
fillData.put("phoneNumber", phoneNo);
|
||||
Map<String, Object> 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.<TbShopTableBooking>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.<TbShopTableBooking>lambdaUpdate()
|
||||
.set(TbShopTableBooking::getStatus, -1)
|
||||
.set(TbShopTableBooking::getUpdateTime, new Date())
|
||||
.eq(TbShopTableBooking::getStatus, 999)
|
||||
.last("and TIMESTAMPDIFF(MINUTE, NOW(), booking_time) >= timeout_minute+15"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<TbThirdPartyCouponRecordMapper, TbThirdPartyCouponRecord>
|
||||
implements TbThirdPartyCouponRecordService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<Map<String, Object>> specList;
|
||||
|
||||
@Transient
|
||||
@TableField(exist = false)
|
||||
private List<ProductGroupVo> proGroupVo;
|
||||
|
||||
public void copy(TbProduct source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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<SuppFlow.ConInfos> conFlows;
|
||||
|
||||
@Transient
|
||||
private List<TbConsInfo> cons;
|
||||
|
||||
|
||||
public void copy(TbShopPurveyorTransact source){
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<TbProductGroup,
|
||||
|
||||
@Query("SELECT groups from TbProductGroup groups where groups.id in :productIds order by groups.sort")
|
||||
List<TbProductGroup> findByIds(List<Integer> productIds);
|
||||
|
||||
@Query("SELECT groups from TbProductGroup groups where groups.shopId = :shopId")
|
||||
List<TbProductGroup> searchGroupByShopId(@Param("shopId") Integer shopId);
|
||||
|
||||
@Modifying
|
||||
@Query("delete from TbProductGroup groups where groups.shopId = :shopId")
|
||||
void clearShopGroup(@Param("shopId") Integer shopId);
|
||||
|
||||
|
||||
}
|
||||
@@ -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<TbProduct, Integer>, JpaSpecificationExecutor<TbProduct> {
|
||||
|
||||
|
||||
@Query("SELECT product from TbProduct product where product.id in :productIds order by product.sort")
|
||||
List<TbProduct> findByIds(List<Integer> 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<TbProduct> findPackageByShopId(@Param("shopId") String shopId);
|
||||
|
||||
|
||||
@Query("SELECT product from TbProduct product where product.shopId = :shopId and product.status=1 and product.isDel=0")
|
||||
List<TbProduct> 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<Integer> 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<TbProduct, Integer>,
|
||||
@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<TbProduct, Integer>,
|
||||
@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);
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,12 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
|
||||
@Query("SELECT sku FROM TbProductSku sku WHERE sku.productId = :productId and sku.isDel=0")
|
||||
List<TbProductSku> searchSku(@Param("productId")String productId);
|
||||
|
||||
@Query("SELECT sku FROM TbProductSku sku WHERE sku.shopId = :shopId and sku.isDel=0")
|
||||
List<TbProductSku> 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<TbProductSku, Inte
|
||||
@Modifying
|
||||
@Query("update TbProductSku set salePrice = :salePrice where productId= :productId")
|
||||
void upSalePrice(@Param("productId") String productId, @Param("lowPrice") BigDecimal salePrice);
|
||||
|
||||
@Query(value =
|
||||
"SELECT " +
|
||||
" sum( real_sales_number )," +
|
||||
" product_id " +
|
||||
" FROM" +
|
||||
" tb_product_sku " +
|
||||
" WHERE" +
|
||||
" product_id IN :ids" +
|
||||
" GROUP BY" +
|
||||
" product_id", nativeQuery = true)
|
||||
List<Object[]> searchProRealSalesNumber(@Param("ids") List<Integer> ids);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<TbProductSpec, Integer>, JpaSpecificationExecutor<TbProductSpec> {
|
||||
|
||||
@Query("SELECT spec FROM TbProductSpec spec WHERE spec.id IN :ids")
|
||||
List<TbProductSpec> searchSpec(@Param("ids")List<Integer> ids);
|
||||
List<TbProductSpec> searchSpec(@Param("ids") List<Integer> 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<TbProductSpec> searchSpecByShopId(@Param("shopId") String shopId);
|
||||
|
||||
@Modifying
|
||||
@Query("delete FROM TbProductSpec spec WHERE spec.shopId = :shopId")
|
||||
void clearShopSpec(@Param("shopId") String shopId);
|
||||
}
|
||||
@@ -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<TbShopCategory,
|
||||
|
||||
@Query("SELECT category FROM TbShopCategory category where category.id IN :ids ")
|
||||
List<TbShopCategory> searchCategory(@Param("ids")List<Integer> ids);
|
||||
@Query("SELECT category FROM TbShopCategory category where category.shopId = :shopId and (category.pid is null or category.pid = '')")
|
||||
List<TbShopCategory> searchCategoryByShopId(@Param("shopId") String shopId);
|
||||
|
||||
@Modifying
|
||||
@Query("delete FROM TbShopCategory category where category.shopId = :shopId")
|
||||
void clearShopCategory(@Param("shopId") String shopId);
|
||||
}
|
||||
@@ -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<TbShopUnit, Integer>
|
||||
|
||||
@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<TbShopUnit> searchUnitByShopId(@Param("shopId")String shopId);
|
||||
|
||||
@Modifying
|
||||
@Query("delete FROM TbShopUnit unit WHERE unit.shopId = :shopId")
|
||||
void clearShopUnit(@Param("shopId")String shopId);
|
||||
}
|
||||
@@ -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<TbShopUserDutyDetail,Integer> {
|
||||
|
||||
|
||||
@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<Object[]> searchUUserDutyDetail(@Param("ids") List<Integer> ids);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.ysk.cashier.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PhpCommonResp<T> {
|
||||
private String code;
|
||||
private String msg;
|
||||
private long time;
|
||||
private T data;
|
||||
}
|
||||
@@ -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<String, Object> params);
|
||||
|
||||
/**
|
||||
* 商家提交开票信息
|
||||
*/
|
||||
JSONObject subInvoicing(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 项目分类
|
||||
*/
|
||||
JSONObject industry(BindingDto bindingDto);
|
||||
|
||||
|
||||
/**
|
||||
* 计算税额
|
||||
*/
|
||||
JSONObject storeSe(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 数电发票类型
|
||||
*/
|
||||
JSONArray digitalInvoice();
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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<String, Object> getActivateCoupon(Integer shopId, String code);
|
||||
|
||||
Map<String, Object> checkCoupon(CheckCouponDTO checkCouponDTO);
|
||||
|
||||
Map<String, Object> revokeCoupon(CheckCouponDTO checkCouponDTO);
|
||||
|
||||
Map<String, Object> getState(Integer shopId);
|
||||
}
|
||||
@@ -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<String, Object> 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<String, Object> 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<Object> 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<String, Object> 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<String> 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<String, Object> 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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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> 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<Object> entity;
|
||||
if (data != null) {
|
||||
Map<String, Object> map = BeanUtil.beanToMap(data);
|
||||
map.put("title", shopInfo.getShopName());
|
||||
entity = new HttpEntity<>(map, headers);
|
||||
} else {
|
||||
entity = new HttpEntity<>(new HashMap<String, Object>(){{
|
||||
put("title", shopInfo.getShopName());
|
||||
}},headers);
|
||||
}
|
||||
|
||||
// 发起请求
|
||||
ResponseEntity<PhpCommonResp> 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<String, Object> getActivateCoupon(Integer shopId, String code) {
|
||||
return exec("/meituan/fulfilmentcertificateprepare", shopId, new HashMap<String, Object>(){{
|
||||
put("code", code);
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> checkCoupon(CheckCouponDTO checkCouponDTO) {
|
||||
return exec("/meituan/certificateprepare", checkCouponDTO.getShopId(), checkCouponDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> revokeCoupon(CheckCouponDTO checkCouponDTO) {
|
||||
return exec("/meituan/fulfilmentcertificatecancel", checkCouponDTO.getShopId(), checkCouponDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getState(Integer shopId) {
|
||||
return exec("/meituan/searchstorestatus", shopId, null);
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
TbOrderDetail seatInfo = null;
|
||||
ArrayList<TbFullOrderDetail> 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);
|
||||
|
||||
@@ -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<Object[]> objects = new ArrayList<>();
|
||||
if (!productIdInt.isEmpty()) {
|
||||
objects = tbShopUserDutyDetailRe.searchUUserDutyDetail(productIdInt);
|
||||
objects = tbProductSkuRepository.searchProRealSalesNumber(productIdInt);
|
||||
}
|
||||
//组装
|
||||
List<TbProductVo> 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<TbProductSku> 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<ViewConSku> query = Example.of(viewConSku);
|
||||
List<ViewConSku> 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<String, Object> 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<TbShopUnit> tbShopUnits = CompletableFuture.supplyAsync(() ->
|
||||
// tbShopUnitRepository.searchUnit(Integer.valueOf(StringUtils.isEmpty(tbProduct.getUnitId()) ? null : tbProduct.getUnitId())));
|
||||
//sku
|
||||
CompletableFuture<List<TbProductSku>> tbProductSkus = CompletableFuture.supplyAsync(() ->
|
||||
tbProductSkuRepository.searchSku(tbProduct.getId().toString()));
|
||||
@@ -313,24 +315,20 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
CompletableFuture<TbProductSpec> 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<TbProductSkuResult> 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<BigDecimal> 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<Integer> 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<BigDecimal> 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<Integer> 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<TbProduct> page1 = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size);
|
||||
QueryWrapper<TbProduct> 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<Integer, String> unitMap = new HashMap<>();
|
||||
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbProduct> 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<TbProductSku> tbProductSkus = producSkutMapper.selectList(new LambdaQueryWrapper<TbProductSku>().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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String,Object> 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<String, Object> 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<String, Object> queryAll(TbShopInfoQueryCriteria criteria) {
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
||||
Pageable pageables = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
|
||||
Page<TbShopInfo> page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageables);
|
||||
Page<TbShopInfo> page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageables);
|
||||
return PageUtil.toPage(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbShopInfo> queryChildShop(TbShopInfoQueryCriteria criteria) {
|
||||
List<TbShopInfo> 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<TbShopInfoDto> 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<TbShopInfoDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TbShopInfoDto tbShopInfo : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
Map<String, Object> 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);
|
||||
|
||||
@@ -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<TbShopPurveyorTransact> pageShopPurveyor = tbShopPurveyorTransactRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
|
||||
for (TbShopPurveyorTransact tbShopPurveyorTransact : pageShopPurveyor.getContent()) {
|
||||
if (StringUtils.isNotBlank(tbShopPurveyorTransact.getConInfos())) {
|
||||
List<SuppFlow.ConInfos> conInfos = JSONUtil.parseJSONStrTList(tbShopPurveyorTransact.getConInfos(), SuppFlow.ConInfos.class);
|
||||
tbShopPurveyorTransact.setConFlows(conInfos);
|
||||
List<Integer> collect = conInfos.stream().map(SuppFlow.ConInfos::getConInfoId).collect(Collectors.toList());
|
||||
List<TbConsInfo> cons = tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.in(root.get("id")).value(collect));
|
||||
tbShopPurveyorTransact.setCons(cons);
|
||||
}
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("content", pageShopPurveyor.getContent());
|
||||
map.put("totalElements", pageShopPurveyor.getTotalElements());
|
||||
|
||||
@@ -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<TbShopTable> shopTablePage =
|
||||
mpShopTableService.page(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(criteria.getPage(), criteria.getSize()), query);
|
||||
List<TbShopTable> 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<TbOrderDetail>()
|
||||
.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<Integer> 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<ProductGroupVo.Food> foods = new ArrayList<>();
|
||||
HashMap<String, ProductGroupVo.Food> 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<ProductGroupVo.Food> foods = new ArrayList<>();
|
||||
HashMap<String, ProductGroupVo.Food> 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<TbCashierCart> query = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.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<TbCashierCart> tbCashierCartList, boolean isAdd) {
|
||||
@@ -915,44 +968,45 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
|
||||
|
||||
AtomicReference<TbCashierCart> mealCashierCart = new AtomicReference<>();
|
||||
List<TbProductSku> skuList = new ArrayList<>();
|
||||
if (!skuIds.isEmpty()) {
|
||||
List<TbProductSku> skuList = productSkuRepository.findAllById(skuIds);
|
||||
HashMap<String, TbProductSku> skuMap = new HashMap<>();
|
||||
skuList.forEach(item -> skuMap.put(item.getId().toString(), item));
|
||||
|
||||
ArrayList<Map<String, Object>> infos = new ArrayList<>();
|
||||
records.forEach(item -> {
|
||||
if (item.getProductId() != null && item.getProductId().equals("-999")) {
|
||||
mealCashierCart.set(item);
|
||||
return;
|
||||
}
|
||||
Map<String, Object> 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<Object, List<Map<String, Object>>> groupedByPlaceNum = infos.stream()
|
||||
.collect(Collectors.groupingBy(info -> info.get("placeNum")));
|
||||
|
||||
ArrayList<HashMap<String, Object>> list = new ArrayList<>();
|
||||
groupedByPlaceNum.forEach((k, v) -> {
|
||||
HashMap<String, Object> item = new HashMap<>();
|
||||
item.put("placeNum", k);
|
||||
item.put("info", v);
|
||||
list.add(item);
|
||||
});
|
||||
copyPage.setRecords(list);
|
||||
Map<String, Object> map = BeanUtil.beanToMap(copyPage, false, false);
|
||||
map.put("seatFee", mealCashierCart);
|
||||
return map;
|
||||
skuList = productSkuRepository.findAllById(skuIds);
|
||||
}
|
||||
HashMap<String, TbProductSku> skuMap = new HashMap<>();
|
||||
skuList.forEach(item -> skuMap.put(item.getId().toString(), item));
|
||||
|
||||
return BeanUtil.beanToMap(cartPage);
|
||||
ArrayList<Map<String, Object>> infos = new ArrayList<>();
|
||||
records.forEach(item -> {
|
||||
if (item.getProductId() != null && item.getProductId().equals("-999")) {
|
||||
mealCashierCart.set(item);
|
||||
return;
|
||||
}
|
||||
Map<String, Object> 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<Object, List<Map<String, Object>>> groupedByPlaceNum = infos.stream()
|
||||
.collect(Collectors.groupingBy(info -> info.get("placeNum")));
|
||||
|
||||
ArrayList<HashMap<String, Object>> list = new ArrayList<>();
|
||||
groupedByPlaceNum.forEach((k, v) -> {
|
||||
HashMap<String, Object> item = new HashMap<>();
|
||||
item.put("placeNum", k);
|
||||
item.put("info", v);
|
||||
list.add(item);
|
||||
});
|
||||
copyPage.setRecords(list);
|
||||
Map<String, Object> 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<Integer> couponIds = new ArrayList<>();
|
||||
couponInfoDTO.getProductCoupon().forEach(item -> {
|
||||
@@ -1559,7 +1613,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
* @param updateState
|
||||
* @return
|
||||
*/
|
||||
private OrderPriceDTO createOrderDetailWithCoupon(List<TbCashierCart> fullCashierCarts, TbOrderInfo orderInfo, Integer shopId, boolean updateState, ShopEatTypeInfoDTO shopEatTypeInfoDTO) {
|
||||
private OrderPriceDTO createOrderDetailWithCoupon(List<TbCashierCart> fullCashierCarts, TbOrderInfo orderInfo, Integer shopId,
|
||||
boolean updateState, ShopEatTypeInfoDTO shopEatTypeInfoDTO, Integer isWaitCall) {
|
||||
OrderPriceDTO priceDTO = new OrderPriceDTO();
|
||||
|
||||
List<Integer> 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<TbOrderDetail> orderDetailList, TbOrderInfo orderInfo) {
|
||||
private void updateOrderDetailCanReturn(List<TbOrderDetail> 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<TbCashierCart> cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId());
|
||||
List<TbOrderDetail> 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<Integer> productIds = new ArrayList<>();
|
||||
cashierCarts.forEach(item -> {
|
||||
productIds.add(Integer.valueOf(item.getProductId()));
|
||||
if (item.getProductId() != null) {
|
||||
productIds.add(Integer.valueOf(item.getProductId()));
|
||||
}
|
||||
});
|
||||
List<TbProduct> productList = productMapper.selectBatchIds(productIds);
|
||||
Map<String, TbProduct> productMap = productList.stream()
|
||||
.collect(Collectors.toMap(product -> String.valueOf(product.getId()), product -> product));
|
||||
cashierCarts.forEach(item -> {
|
||||
TbProduct product = productMap.get(item.getProductId());
|
||||
|
||||
Map<String, TbProduct> productMap = new HashMap<>();
|
||||
if (!productIds.isEmpty()) {
|
||||
List<TbProduct> 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<TbCashierCart>()
|
||||
.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<TbOrderDetail> detailList = orderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.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<TbOrderDetail> detailList = orderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.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<TbOrderDetail> detailList = null;
|
||||
if (TableConstant.OrderInfo.PayType.CREDIT_BUYER.equalsVals(oldOrderInfo.getPayType())) {
|
||||
detailList = orderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.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<TbOrderDetail>()
|
||||
.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<String, Object> 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<TbCashierCart> 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<TbCashierCart> 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<Integer> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String,Object> queryAll(TbShopInfoQueryCriteria criteria);
|
||||
|
||||
List<TbShopInfo> 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 /
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 <T> void catchErrNoReturn(Supplier<T> 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);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user