|
|
@@ -86,6 +86,48 @@ public class LifeGroupBuyServiceImpl extends ServiceImpl<LifeGroupBuyMainMapper,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public LifeGroupBuyThali saveThaliNew(LifeGroupBuyDto lifeGroupBuyDto) {
|
|
|
+ JSONObject currentUserInfo = JwtUtil.getCurrentUserInfo();
|
|
|
+ Integer userId = null;
|
|
|
+ if (!ObjectUtils.isEmpty(currentUserInfo)) {
|
|
|
+ userId = currentUserInfo.getInteger("userId");
|
|
|
+ }
|
|
|
+ LifeGroupBuyMain lifeGroupBuyMain = lifeGroupBuyDto.getLifeGroupBuyMain();
|
|
|
+ List<LifeGroupBuyThali> lifeGroupBuyThalis = lifeGroupBuyDto.getLifeGroupBuyThalis();
|
|
|
+ LifeGroupBuyThali lifeGroupBuyThali = null;
|
|
|
+ if (ObjectUtils.isEmpty(lifeGroupBuyMain.getId())) {
|
|
|
+ Integer count = lifeGroupBuyMainMapper.selectCount(new LambdaQueryWrapper<LifeGroupBuyMain>().like(LifeGroupBuyMain::getCreatedTime, DateUtils.formatDate(new Date(), "yyyy-MM-dd")).eq(LifeGroupBuyMain::getStoreId, lifeGroupBuyMain.getStoreId()));
|
|
|
+ lifeGroupBuyMain.setGroupNo("G" + DateUtils.formatDate(new Date(), "yyyyMMdd") + lifeGroupBuyMain.getStoreId() + org.apache.commons.lang3.StringUtils.leftPad(String.valueOf(count + 1), 5, "0"));
|
|
|
+ lifeGroupBuyMain.setCreatedUserId(userId);
|
|
|
+ lifeGroupBuyMainMapper.insert(lifeGroupBuyMain);
|
|
|
+ if (ObjectUtils.isNotEmpty(lifeGroupBuyThalis)) {
|
|
|
+ for (int i = 0; i < lifeGroupBuyThalis.size(); i++) {
|
|
|
+ lifeGroupBuyThali = lifeGroupBuyThalis.get(i);
|
|
|
+ lifeGroupBuyThali.setParentId(lifeGroupBuyMain.getId().toString());
|
|
|
+ lifeGroupBuyThali.setDetailSort(i + 1);
|
|
|
+ lifeGroupBuyThali.setCreatedUserId(userId);
|
|
|
+ lifeGroupBuyThaliMapper.insert(lifeGroupBuyThali);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return lifeGroupBuyThali;
|
|
|
+ } else {
|
|
|
+ lifeGroupBuyMain.setUpdatedUserId(userId);
|
|
|
+ lifeGroupBuyMainMapper.updateById(lifeGroupBuyMain);
|
|
|
+ lifeGroupBuyThaliMapper.update(null, new LambdaUpdateWrapper<LifeGroupBuyThali>().eq(LifeGroupBuyThali::getParentId, lifeGroupBuyMain.getId()).set(LifeGroupBuyThali::getDeleteFlag, 1));
|
|
|
+ if (ObjectUtils.isNotEmpty(lifeGroupBuyThalis)) {
|
|
|
+ for (int i = 0; i < lifeGroupBuyThalis.size(); i++) {
|
|
|
+ lifeGroupBuyThali = lifeGroupBuyThalis.get(i);
|
|
|
+ lifeGroupBuyThali.setParentId(lifeGroupBuyMain.getId().toString());
|
|
|
+ lifeGroupBuyThali.setDetailSort(i + 1);
|
|
|
+ lifeGroupBuyThali.setCreatedUserId(userId);
|
|
|
+ lifeGroupBuyThaliMapper.insert(lifeGroupBuyThali);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return lifeGroupBuyThali;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public IPage<LifeGroupBuyThaliVo> getThaliList(int page, int size, String storeId, String status, String groupName, String groupType) {
|
|
|
QueryWrapper<LifeGroupBuyThaliVo> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq(StringUtils.isNotEmpty(storeId), "store_id", storeId)
|