101captain
2022-01-07 adf7566f482080d9fff9dd4429f308433a0e2c2f
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsOrderServiceImpl.java
@@ -1,5 +1,6 @@
package com.panzhihua.service_community.service.impl;
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.panzhihua.common.model.dtos.property.CommonPage;
@@ -11,12 +12,14 @@
import com.panzhihua.common.utlis.WxPayUtils;
import com.panzhihua.service_community.entity.McsOrder;
import com.panzhihua.service_community.dao.McsOrderDao;
import com.panzhihua.service_community.service.McsMerchantService;
import com.panzhihua.service_community.service.McsOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
@@ -40,9 +43,11 @@
    @Value("${min.app.mchId}")
    private String mchId;
    //@Value("${min.app.notifyUrl}")
    private String notifyUrl="www.baidu.com";
    private String notifyUrl="http://387405oo37.zicp.vip/mcsOrder/wxNotify";
    @Resource
    private RabbitTemplate rabbitTemplate;
    @Resource
    private McsMerchantService mcsMerchantService;
    @Override
    public R pageList(CommonPage commonPage) {
        return R.ok(this.baseMapper.pageList(new Page(commonPage.getPage(),commonPage.getSize()),commonPage));
@@ -54,7 +59,7 @@
        BeanUtils.copyProperties(mcsOrderVO,mcsOrder);
        mcsOrder.setStatus(0);
        mcsOrder.setCreateTime(new Date());
        mcsOrder.setOrderNo(DateUtils.getCurrentDateStr());
        mcsOrder.setOrderNo(DateUtils.getCurrentDateStrNoSignal());
        this.baseMapper.insert(mcsOrder);
        rabbitTemplate.convertAndSend("mcsOrder.exchange", "mcsOrder.key", mcsOrder, message -> {
            message.getMessageProperties().setHeader("x-delay",  1000 * 1800);
@@ -79,7 +84,7 @@
                }
                // 调用wx支付
                String result= WxPayUtils.h5pay(appid, mchId, payKey, notifyUrl, "点亮支付", mcsOrderVO.getOpenId(),
                        mcsOrderVO.getOrderNo().toString(), money,mcsOrderVO.getTradeType());
                        mcsOrder.getOrderNo(), money,mcsOrderVO.getTradeType());
                return R.ok(result);
            } catch (Exception e) {
                log.error("调用微信支付异常,异常原因:" + e.getMessage());
@@ -102,9 +107,16 @@
    }
    @Override
    @Transactional
    public R notify(McsOrderVO mcsOrderVO) {
        McsOrder mcsOrder=new McsOrder();
        BeanUtils.copyProperties(mcsOrderVO,mcsOrder);
        return R.ok(this.baseMapper.updateById(mcsOrder));
        McsOrder mcsOrderBase=this.baseMapper.selectOne(new QueryWrapper<McsOrder>().lambda().eq(McsOrder::getOrderNo,mcsOrderVO.getOrderNo()));
        mcsOrderBase.setStatus(2);
        mcsOrderBase.setPayNo(mcsOrderVO.getPayNo());
        mcsOrderBase.setPayTime(mcsOrderVO.getPayTime());
        int i=this.baseMapper.updateById(mcsOrderBase);
        if(i>0){
            mcsMerchantService.updateOrAddMcsMerchantAfterOrder(mcsOrderBase.getMerchantName(),mcsOrderBase.getConfigId(),mcsOrderBase.getUserId());
        }
        return R.ok();
    }
}