Commit dacc75bf by huluobin

商城订单代理打折

parent 78533c3b
......@@ -63,9 +63,12 @@ public class MallOrderPayServiceImpl implements MallOrderPayService {
private final WxProperties wxProperties;
private final IAgentUserService agentUserService;
private WxPayUnifiedOrderRequest buildPayParam(MallOrder mallOrder) throws UnknownHostException {
Customer customer = customerService.getById(mallOrder.getCustomerId());
//代理打折
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
String ip = Inet4Address.getLocalHost().getHostAddress();
......@@ -96,8 +99,7 @@ public class MallOrderPayServiceImpl implements MallOrderPayService {
@Resource
AgentUserMapper agentUserMapper;
@Resource
IAgentUserService agentUserService;
@Transactional(timeout = 10000)
@Override
......
......@@ -4,10 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gogirl.application.common.IAgentUserService;
import com.gogirl.application.order.mall.MallCustomerAddressService;
import com.gogirl.application.order.mall.MallOrderDetailService;
import com.gogirl.application.order.mall.MallOrderService;
import com.gogirl.application.order.mall.MallShoppingCartService;
import com.gogirl.application.user.customer.CustomerService;
import com.gogirl.domain.common.AgentUser;
import com.gogirl.domain.order.mall.*;
import com.gogirl.domain.product.mall.MallProduct;
import com.gogirl.domain.store.store.StoreManage;
......@@ -35,6 +38,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
......@@ -283,6 +287,8 @@ public class MallOrderServiceImpl extends ServiceImpl<MallOrderMapper, MallOrder
});
}
this.agentDiscount(mallOrder);
//设置命令结果
cmd.setExecutionResult(mallOrder.getId());
log.info("用户{}下单结束,时间{},耗时{}", cmd.getCustomerId(), System.currentTimeMillis(), System.currentTimeMillis() - time);
......@@ -389,6 +395,7 @@ public class MallOrderServiceImpl extends ServiceImpl<MallOrderMapper, MallOrder
});
}
this.agentDiscount(mallOrder);
//设置命令结果
cmd.setExecutionResult(mallOrder.getId());
log.info("用户{}下单结束,时间{},耗时{}", cmd.getCustomerId(), System.currentTimeMillis(), System.currentTimeMillis() - time);
......@@ -396,6 +403,25 @@ public class MallOrderServiceImpl extends ServiceImpl<MallOrderMapper, MallOrder
}
@Resource
CustomerService customerService;
@Resource
IAgentUserService agentUserService;
private void agentDiscount(MallOrder mallOrder) {
Customer customer = customerService.getById(mallOrder.getCustomerId());
AgentUser agentUser = agentUserService.selectByPhone(customer.getPhone());
if (agentUser.getDiscount().compareTo(BigDecimal.ONE) < 0) {
mallOrder.setTotalDiscountAmount(mallOrder.getTotalAmount().multiply(BigDecimal.ONE.subtract(agentUser.getDiscount())));
mallOrder.setTotalPayAmount(mallOrder.getTotalAmount().multiply(agentUser.getDiscount()));
} else {
mallOrder.setTotalPayAmount(mallOrder.getTotalAmount());
}
mallOrderMapper.updateById(mallOrder);
}
@Override
public IPage<MallOrder> listMallOrderAggregate(ListMallOrderRequest request) {
......
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