liujie
10 天以前 221b72ce4da14b97dc5aa5afe43eae2c68fb88b0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderServiceImpl.java
@@ -20,6 +20,7 @@
import com.ruoyi.system.pojo.dto.OrderPageDTO;
import com.ruoyi.system.pojo.model.DailyStatistics;
import com.ruoyi.system.pojo.vo.*;
import com.ruoyi.system.service.CompanyTypeService;
import com.ruoyi.system.service.OrderService;
import com.ruoyi.system.wx.RefundCallbackResult;
import com.ruoyi.system.wx.WechatPayService;
@@ -63,6 +64,13 @@
    private RedisCache redisCache;
    @Resource
    private QichachaMapper qichachaMapper;
    @Resource
    private CompanyTypeService companyTypeService;
    @Resource
    private AccountDetailMapper accountDetailMapper;
    @Override
@@ -160,12 +168,24 @@
            throw new ServiceException("公司不存在");
        }
        BusinessVO vo = new BusinessVO();
        // 先查企业工商信息 更新数据
        JSONObject jsonObject = getQiChaChaBasicDetailsCompany(company.getCompanyName());
        company.setOperName(jsonObject.getString("OperName"));
        company.setBelongOrg(jsonObject.getString("BelongOrg"));
        company.setRegistrationStatus(jsonObject.getString("Status"));
              company.setRegisteredCapital(jsonObject.getString("RegisteredCapital"));
        company.setPaidInFunds(jsonObject.getString("PaidUpCapital"));
        companyMapper.updateById(company);
        BeanUtils.copyProperties(company, vo);
        vo.setNewRegisteredCapital(company.getRealRegisteredCapital());
        vo.setPlace(company.getCity()+company.getProvince()+company.getArea());
        //todo 再查企业工商信息 覆盖掉之前的
        JSONObject area = (JSONObject) jsonObject.get("Area");
        vo.setPlace(area.getString("Province")+"-"+area.getString("City")+"-"+area.getString("County"));
        vo.setCompanyCategoryName(jsonObject.getString("EconKind"));
        String name = companyTypeService.getById(company.getCompanyCategory()).getName();
        vo.setCompanyCategoryName(name);
        return vo;
    }
@@ -197,22 +217,7 @@
    /**
     * 经营异常核查
     * @param companyName
     * @return
     * VerifyResult  int   数据是否存在(1-存在,0-不存在)
     * Data     List<Object>  数据信息
     * Data:[{
     *     AddReason  列入经营异常名录原因
     *     AddDate   列入日期
     *     RomoveReason  移出经营异常名录原因(保留字段)
     *     RemoveDate   移出日期(保留字段)
     *     DecisionOffice     作出决定机关
     *     RemoveDecisionOffice  移出决定机关(保留字段)
     * }]
     * Status
     * Message
     * OrderNumber
     * 查询工商信息
     */
    public  JSONObject getQiChaChaBasicDetailsCompany(String companyName){
        Object cacheObject = redisCache.getCacheObject("qichacha_" +"basic_"+ companyName);
@@ -315,12 +320,12 @@
    public R change(String id) {
//        System.err.println(getReport("ZZD20250508017232394218445"));
        ChangeVO changeVO = new ChangeVO();
       /* Company companyInfo = companyMapper.selectById(id);
        Company companyInfo = companyMapper.selectById(id);
        if (null == companyInfo || companyInfo.getIsDelete() != 0) {
            throw new ServiceException("公司不存在");
        }*/
//        JSONObject jsonObject=getReport(companyInfo.getLink().split("=")[1]);
        JSONObject jsonObject=getReport("ZZD20250508017232394218445");
        }
        JSONObject jsonObject=getReport(companyInfo.getLink().split("=")[1]);
//        JSONObject jsonObject=getReport("ZZD20250508017232394218445");
        if (!"1001".equals(jsonObject.getString("code"))){
            return R.fail(jsonObject.get("msg"));
        }
@@ -343,12 +348,12 @@
    @Override
    public R tax(String id) {
        TaxVO taxVO = new TaxVO();
       /* Company companyInfo = companyMapper.selectById(id);
        Company companyInfo = companyMapper.selectById(id);
        if (null == companyInfo || companyInfo.getIsDelete() != 0) {
            throw new ServiceException("公司不存在");
        }*/
//        JSONObject jsonObject=getReport(companyInfo.getLink().split("=")[1]);
        JSONObject jsonObject=getReport("ZZD20250508017232394218445");
        }
        JSONObject jsonObject=getReport(companyInfo.getLink().split("=")[1]);
//        JSONObject jsonObject=getReport("ZZD20250508017232394218445");
        if (!"1001".equals(jsonObject.getString("code"))){
            return R.fail(jsonObject.get("msg"));
        }
@@ -418,12 +423,12 @@
    @Override
    public R invoice(String id) {
        InvoiceVO vo = new InvoiceVO();
       /* Company companyInfo = companyMapper.selectById(id);
        Company companyInfo = companyMapper.selectById(id);
        if (null == companyInfo || companyInfo.getIsDelete() != 0) {
            throw new ServiceException("公司不存在");
        }*/
//        JSONObject jsonObject=getReport(companyInfo.getLink().split("=")[1]);
        JSONObject jsonObject=getReport("ZZD20250508017232394218445");
        }
        JSONObject jsonObject=getReport(companyInfo.getLink().split("=")[1]);
//        JSONObject jsonObject=getReport("ZZD20250508017232394218445");
        if (!"1001".equals(jsonObject.getString("code"))){
            return R.fail(jsonObject.get("msg"));
        }
@@ -607,6 +612,15 @@
            order.setRefundTime(LocalDateTime.now());
            companyMapper.updateById(company);
        }else{
            // 判断是否能退
            if(order.getShareUserId()!=null){
                User user = appUserMapper.selectById(order.getShareUserId());
                if(user.getBalance().doubleValue()<order.getCommissionPrice().doubleValue()){
                    throw new ServiceException("退款失败,卖家上级余额不足");
                }
            }
            R r = refundPayMoney(order);//退款
            if (200 == r.getCode()) {
                //退款申请成功
@@ -676,12 +690,27 @@
        order.setIsRefund(1);
        order.setRefundTime(LocalDateTime.now());
        this.baseMapper.updateById(order);
        //将分佣次数加回
        User user = appUserMapper.selectById(order.getUserId());
        User inviter = appUserMapper.selectById(user.getInviteId());
        User inviter = appUserMapper.selectById(company.getUserId());
        if (inviter!=null && inviter.getIsDelete()==0){
            inviter.setInviteNum(inviter.getInviteNum()+1);
            appUserMapper.updateById(inviter);
        }
        // 分佣退回
        if(order.getShareUserId()!=null && order.getCommissionPrice().doubleValue()>0){
            User user = appUserMapper.selectById(order.getShareUserId());
            user.setBalance(user.getBalance().subtract(order.getCommissionPrice()));
            appUserMapper.updateById(user);
            AccountDetail accountDetail = new AccountDetail();
            accountDetail.setUserId(order.getShareUserId());
            accountDetail.setType(2);
            accountDetail.setCategory(4);
            accountDetail.setSourceId(order.getId());
            accountDetail.setMoney(order.getCommissionPrice());
            accountDetail.setRemark("订单取消分佣退回");
            accountDetailMapper.insert(accountDetail);
        }
        //商品状态修改
@@ -737,7 +766,8 @@
    @Override
    public FinanceFlowsTopVO financeTop(FinanceFlowsDTO dto) {
        return this.baseMapper.financeTop(dto);
        FinanceFlowsTopVO financeFlowsTopVO = this.baseMapper.financeTop(dto);
        return financeFlowsTopVO;
    }
    @Override