CeDo
2021-04-22 be2d7ec232fbd22b5e46ec133485ea751520636d
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopOrderServiceImpl.java
@@ -8,6 +8,7 @@
import com.panzhihua.common.model.dtos.PageDTO;
import com.panzhihua.common.model.dtos.shop.*;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.common.utlis.WxPayUtils;
import com.panzhihua.service_community.dao.ComShopOrderDAO;
import com.panzhihua.service_community.model.dos.ComShopOrderDO;
@@ -321,6 +322,11 @@
                    orderGoodsDOList.forEach(orderGoods -> {
                        ComShopOrderGoodsVO orderGoodsVO = new ComShopOrderGoodsVO();
                        BeanUtils.copyProperties(orderGoods,orderGoodsVO);
                        //根据商品规格id查询商品规格
                        ComShopGoodsAttrDO goodsAttrDO = comShopGoodsAttrDAO.selectById(orderGoods.getGoodsAttrId());
                        if(goodsAttrDO != null){
                            orderGoodsVO.setGoodsAttr(goodsAttrDO.getGoodsAttr());
                        }
                        orderGoodsVO.setNum(orderGoods.getAmount());
                        orderGoodsVO.setGoodsPic(orderGoods.getGoodsAttrPic());
                        orderGoodsVO.setPrice(orderGoods.getGoodsAttrPrice());
@@ -378,6 +384,11 @@
                orderGoodsVO.setNum(orderGoods.getAmount());
                orderGoodsVO.setGoodsPic(orderGoods.getGoodsAttrPic());
                orderGoodsVO.setPrice(orderGoods.getGoodsAttrPrice());
                //根据商品规格id查询商品规格
                ComShopGoodsAttrDO goodsAttrDO = comShopGoodsAttrDAO.selectById(orderGoods.getGoodsAttrId());
                if(goodsAttrDO != null){
                    orderGoodsVO.setGoodsAttr(goodsAttrDO.getGoodsAttr());
                }
                orderGoodsVOS.add(orderGoodsVO);
                sbr.append(orderGoods.getGoodsName() + " " );
            });
@@ -548,8 +559,13 @@
            return R.fail("订单不存在");
        }
        if(!(comShopOrderDO.getStatus()==2)
                || !(comShopOrderDO.getDeleteStatus()==1)){
                || !(comShopOrderDO.getDeliveryStatus()==1)){
            return R.fail("订单发货失败,订单状态不允许发货");
        }
        ComShopStoreDO storeDO  = comShopStoreDAO.selectById(comShopOrderDO.getStoreId());
        if(storeDO.getDeliveryType()!=2){
            return R.fail("该商家不支持通过快递物流发货");
        }
        comShopOrderDO.setDeliveryStatus(2);
        comShopOrderDO.setDeliveryType(2);
@@ -569,11 +585,17 @@
        if(comShopOrderDO==null){
            return R.fail("订单不存在");
        }
        if(!(comShopOrderDO.getStatus()==2)){
        if(!(comShopOrderDO.getStatus()==2)
                || !(comShopOrderDO.getDeliveryStatus()==1)){
            return R.fail("当前订单不能配送");
        }
        ComShopStoreDO storeDO  = comShopStoreDAO.selectById(comShopOrderDO.getStoreId());
        if(storeDO.getDeliveryType()!=1){
            return R.fail("该商家不支持通过商家配送");
        }
        comShopOrderDO.setDeliveryStatus(4);
        comShopOrderDO.setDeliveryType(1);
        comShopOrderDO.setStatus(3);
        int updated = comShopOrderDAO.updateById(comShopOrderDO);
        if(updated==1){
            return R.ok("开始配送");
@@ -590,6 +612,10 @@
        if(!(comShopOrderDO.getDeliveryStatus() == 4)){
            return R.fail("订单还未开始配送");
        }
        if(!(comShopOrderDO.getStatus() == 3)){
            return R.fail("订单还未发货");
        }
        comShopOrderDO.setStatus(4);
        comShopOrderDO.setDeliveryStatus(5);
        int updated = comShopOrderDAO.updateById(comShopOrderDO);
        if(updated==1){
@@ -601,7 +627,7 @@
    @Override
    public R shopOrderExportData(ComShopOrderExportDTO comShopOrderExportDTO) {
        Page page = new Page();
        page.setSize(1000);
        page.setSize(10000);
        page.setCurrent(1);
        IPage<ExcelShopOrderDTO>  excelShopOrderDTO = comShopOrderDAO.selectOrderExport(page, comShopOrderExportDTO);
        return R.ok(excelShopOrderDTO.getRecords());
@@ -610,7 +636,7 @@
    @Override
    public R shopOrderFundsExportData(ComShopFundsExportDTO comShopFundsExportDTO) {
        Page page = new Page();
        page.setSize(1000);
        page.setSize(10000);
        page.setCurrent(1);
        IPage<ExcelShopFundsDTO>  excelShopFundsDTO = comShopOrderDAO.selectFundsExport(page, comShopFundsExportDTO);
        return R.ok(excelShopFundsDTO.getRecords());
@@ -619,6 +645,12 @@
    @Override
    public R getFundsStat(Long userId) {
        ComShopFundsVO comShopFundsVO = comShopOrderDAO.queryStatis(userId);
        if(comShopFundsVO==null){
            comShopFundsVO = new ComShopFundsVO();
            comShopFundsVO.setMonthTotal(new BigDecimal(0));
            comShopFundsVO.setTodayTotal(new BigDecimal(0));
            comShopFundsVO.setWeekTotal(new BigDecimal(0));
        }
        return R.ok(comShopFundsVO);
    }
@@ -674,11 +706,13 @@
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void wxOrderPayNotify(WxPayNotifyOrderDTO wxPayNotifyOrderDTO){
        log.info("微信订单支付回调开始处理逻辑");
        if(StringUtils.isEmpty(wxPayNotifyOrderDTO.getOrderTradeNo())){
            log.error("微信支付回调失败,订单号为空");
            return;
        }
        log.info("微信订单支付回调开始查询订单");
        //查询订单
        ComShopOrderDO shopOrderDO = this.baseMapper.selectOne(new QueryWrapper<ComShopOrderDO>().lambda().eq(ComShopOrderDO::getOrderNo,wxPayNotifyOrderDTO.getOrderTradeNo()));
        if(shopOrderDO == null){
@@ -688,9 +722,9 @@
        shopOrderDO.setStatus(ComShopOrderDO.status.dfh);
        shopOrderDO.setPayType(ComShopOrderDO.payType.wx);
        shopOrderDO.setPayStatus(ComShopOrderDO.payStatus.yes);
        shopOrderDO.setPayAmount(BigDecimal.valueOf(Integer.parseInt(wxPayNotifyOrderDTO.getCashFee()) / 100));
        shopOrderDO.setPayAmount(BigDecimal.valueOf(Double.valueOf(wxPayNotifyOrderDTO.getCashFee()) / 100));
        shopOrderDO.setWxTardeNo(wxPayNotifyOrderDTO.getWxTradeNo());
        shopOrderDO.setPayTime(new Date(Long.parseLong(wxPayNotifyOrderDTO.getPayTime())));
        shopOrderDO.setPayTime(DateUtils.stringToDate(wxPayNotifyOrderDTO.getPayTime(),new SimpleDateFormat("yyyyMMddHHmmss")));
        this.baseMapper.updateById(shopOrderDO);
        //查询订单商品
@@ -770,4 +804,9 @@
        }
        return R.ok(shopOrderVO);
    }
    public static void main(String[] args) {
        BigDecimal one = BigDecimal.valueOf(Double.valueOf("1") / 100);
        System.out.println();
    }
}