Commit 211d02cc by huluobin

订单详情接口修改

parent 862ac14a
......@@ -1028,22 +1028,23 @@ public class OrderManageServiceImpl extends ServiceImpl<OrderManageMapper, Order
*/
private OrderManage aggregateOrderManage(OrderManage orderManage) {
Integer id = orderManage.getId();
//1、订单详情
List<OrderServe> orderServeList = orderServeMapper.selectList(new LambdaQueryWrapper<OrderServe>().eq(OrderServe::getOrderId, id));
orderManage.setListOrderServer(orderServeList);
//2、订单关联的卡券
List<CouponCustomerRelevance> couponCustomerRelevanceList = couponCustomerRelevanceService.list(
new LambdaQueryWrapper<CouponCustomerRelevance>().eq(CouponCustomerRelevance::getOrderId, id)
);
orderManage.setCouponCustomerRelevanceList(couponCustomerRelevanceList);
//3、订单关联的次卡
List<TimesCardUsedRecord> timesCardUsedRecordList = timesCardUsedRecordService.list(
new LambdaQueryWrapper<TimesCardUsedRecord>().eq(TimesCardUsedRecord::getOrderId, id)
);
orderManage.setCouponCustomerRelevanceList(couponCustomerRelevanceList);
orderManage.setListTimesCardRecord(timesCardUsedRecordList);
//4、订单服务关联的美甲师列表
orderManage.getListOrderServer()
.forEach(orderServe -> {
List<String> ids = Lists.newArrayList(orderServe.getTechnicianId().split(","));
......@@ -1054,6 +1055,7 @@ public class OrderManageServiceImpl extends ServiceImpl<OrderManageMapper, Order
.collect(Collectors.toList()));
});
//订单服务实际时长计算
orderManage.getListOrderServer().forEach(orderServe -> {
if (orderServe.getEndTime() != null && orderServe.getStartTime() != null) {
orderServe.setActualServeDuration((int) (orderServe.getEndTime().getTime() -
......@@ -1061,8 +1063,18 @@ public class OrderManageServiceImpl extends ServiceImpl<OrderManageMapper, Order
}
});
//5、订单关联的预约
ScheduleManage scheduleManage = scheduleManageMapper.selectById(orderManage.getScheduledId());
orderManage.setScheduleManage(scheduleManage);
//6、下单用户
Customer customer = customerService.getById(orderManage.getOrderUser());
orderManage.setCustomer(customer);
//7、支付用户
Customer payCustomer = customerService.getById(orderManage.getPayUser());
orderManage.setPayCustomer(payCustomer);
return orderManage;
}
}
......
......@@ -27,10 +27,10 @@ public interface CustomerBalanceService extends IService<CustomerBalance> {
/**
* 查看消费记录
*
* @param customerId
* @param pageNum
* @param pageSize
* @return
* @param customerId 用户id
* @param pageNum 页码
* @param pageSize 分页长度
* @return 用户消费记录分页查询结果
*/
PageInfo<CustomerBalanceRecord> getBalanceRecordCard(Integer customerId, int pageNum, int pageSize);
}
......@@ -8,6 +8,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gogirl.application.order.serve.OrderManageService;
import com.gogirl.application.user.customer.CustomerBalanceService;
import com.gogirl.domain.order.serve.OrderManage;
import com.gogirl.domain.store.store.StoreUser;
import com.gogirl.domain.user.customer.CustomerBalance;
import com.gogirl.domain.user.customer.CustomerBalanceRecord;
......@@ -15,6 +16,7 @@ import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.mapper.store.store.UserManageMapper;
import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceMapper;
import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceRecordMapper;
import com.gogirl.infrastructure.mapper.user.customer.CustomerMapper;
import com.gogirl.shared.user.command.ConsumerCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
......@@ -44,6 +46,9 @@ public class CustomerBalanceServiceImpl extends ServiceImpl<CustomerBalanceMappe
@Resource
private OrderManageService orderManageService;
@Resource
CustomerMapper customerMapper;
@Override
public CustomerBalance getCustomerBalance(int customerId) {
CustomerBalance customerBalance = customerBalanceMapper.selectOne(new LambdaQueryWrapper<CustomerBalance>()
......@@ -102,11 +107,17 @@ public class CustomerBalanceServiceImpl extends ServiceImpl<CustomerBalanceMappe
param.setCustomerId(customerId);
PageHelper.startPage(pageNum, pageSize);
//1、查询消费记录
List<CustomerBalanceRecord> list = balanceRecordDao.getBalanceRecordCard(customerId);
//2、如果是预约订单消费,关联查询预约订单
list.stream()
.filter(balanceRecord -> balanceRecord.getType().equals(-1))
.forEach(balanceRecord -> {
balanceRecord.setOrderManage(orderManageService.queryOrder(Integer.valueOf(balanceRecord.getOrderId())));
//消费记录关联的订单
OrderManage orderManage = orderManageService.queryOrder(Integer.valueOf(balanceRecord.getOrderId()));
balanceRecord.setOrderManage(orderManage);
//deprecated
if (balanceRecord.getOrderAmount() != null && balanceRecord.getOrderAmount() != 0 && balanceRecord.getOrderManage() != null) {
balanceRecord.getOrderManage().setTotalPrice(new BigDecimal(balanceRecord.getOrderAmount()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP));
}
......@@ -133,8 +144,6 @@ public class CustomerBalanceServiceImpl extends ServiceImpl<CustomerBalanceMappe
}
}
PageInfo<CustomerBalanceRecord> pageInfo = new PageInfo<>(list);
return pageInfo;
return new PageInfo<>(list);
}
}
package com.gogirl;
package com.gogirl.infrastructure.common.exception;
import com.gogirl.infrastructure.common.base.JsonResult;
......
......@@ -598,7 +598,10 @@ public class Schedule {
private final GogirlProperties gogirlProperties;
private OrderManageMapper orderManageMapper;
@Scheduled(cron = "0 0/1 * * * *")
/**
* 每30分钟一次评价提醒图推送
*/
@Scheduled(cron = "0 0/30 * * * *")
public void testPaper() {
log.info("评价提醒推送");
Date date = new Date(System.currentTimeMillis() - gogirlProperties.getTestPaperTime() * 60000L);
......
......@@ -2,20 +2,21 @@ package com.gogirl.infrastructure.util;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.*;
import java.security.AlgorithmParameters;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
import java.security.spec.InvalidParameterSpecException;
/**
* AES加密
*
* @author liuyazhuang
*/
public class AES {
public class AESUtil {
public static boolean initialized = false;
......@@ -26,8 +27,15 @@ public class AES {
initialized = true;
}
// 生成iv
public static AlgorithmParameters generateIV(byte[] iv) throws Exception {
/**
* 生成iv
*
* @param iv iv
* @return AlgorithmParameters
* @throws NoSuchAlgorithmException noSuchAlgorithmException
* @throws InvalidParameterSpecException invalidParameterSpecException
*/
public static AlgorithmParameters generateIV(byte[] iv) throws NoSuchAlgorithmException, InvalidParameterSpecException {
AlgorithmParameters params = AlgorithmParameters.getInstance("AES");
params.init(new IvParameterSpec(iv));
return params;
......@@ -37,33 +45,18 @@ public class AES {
* AES解密
*
* @param content 密文
* @return
* @throws InvalidAlgorithmParameterException
* @throws NoSuchProviderException
* @return result
* @throws Exception e
*/
public byte[] decrypt(byte[] content, byte[] keyByte, byte[] ivByte) throws InvalidAlgorithmParameterException {
public byte[] decrypt(byte[] content, byte[] keyByte, byte[] ivByte) throws Exception {
initialize();
try {
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
Key sKeySpec = new SecretKeySpec(keyByte, "AES");
cipher.init(Cipher.DECRYPT_MODE, sKeySpec, generateIV(ivByte));// 初始化
byte[] result = cipher.doFinal(content);
return result;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (NoSuchProviderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
// 初始化
cipher.init(Cipher.DECRYPT_MODE, sKeySpec, generateIV(ivByte));
return cipher.doFinal(content);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
......
......@@ -6,6 +6,11 @@ import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Stream;
/**
* Java8求笛卡尔积
*
* @param <T>
*/
public class Prefix<T> {
private final T value;
private final Prefix<T> parent;
......@@ -34,8 +39,7 @@ public class Prefix<T> {
* @param <C>
* @return
*/
public static <T, C extends Collection<T>> Stream<C> ofCombinations(
Collection<? extends Collection<T>> values, Supplier<C> supplier) {
public static <T, C extends Collection<T>> Stream<C> ofCombinations(Collection<? extends Collection<T>> values, Supplier<C> supplier) {
if (values.isEmpty())
return Stream.empty();
return comb(new ArrayList<>(values), 0, null, supplier);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment