Administrator
2025-07-30 db8566a1e50e55039fc4acd65d4f8248ba6783b4
src/main/java/cc/mrbird/febs/pay/service/impl/XcxPayServiceImpl.java
@@ -23,6 +23,7 @@
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
@@ -41,10 +42,7 @@
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Slf4j
@Service
@@ -70,6 +68,8 @@
    @Autowired
    private MallMemberWithdrawMapper mallMemberWithdrawMapper;
    private final IMallMoneyFlowService mallMoneyFlowService;
    private final ClothesTypeMapper clothesTypeMapper;
    private final ClothesOrderMapper clothesOrderMapper;
    @Autowired
    RedisUtils redisUtils;
@@ -208,6 +208,34 @@
        }
        mallOrderInfo.setWxOrderNo(payData.getPrepay_id());
        mallOrderInfoMapper.updateById(mallOrderInfo);
        return payData;
    }
    @Override
    public BrandWCPayRequestData startPayment(ClothesOrder orderInfo) throws Exception {
        BigDecimal unit = new BigDecimal("100");
        BigDecimal money = new BigDecimal(orderInfo.getRealAmount().toString());
        BrandWCPayRequestData payData;
        ClothesType clothesType = clothesTypeMapper.selectById(orderInfo.getTypeId());
        String productNames = clothesType.getName();
        MallMember mallMember = mallMemberMapper.selectById(orderInfo.getMemberId());
        Boolean debug = xcxProperties.getDebug();
        if (debug) {
            payData = weixinServiceUtil.createOrder("[测试]" + productNames, orderInfo.getOrderNo(),
                    1, mallMember.getOpenId(), String.valueOf(orderInfo.getId()));
        } else {
            payData = weixinServiceUtil.createOrder(productNames, orderInfo.getOrderNo(),
                    unit.multiply(money).intValue(),mallMember.getOpenId(), String.valueOf(orderInfo.getId()));
        }
        orderInfo.setPayOrderNo(payData.getPrepay_id());
        clothesOrderMapper.update(null,
                Wrappers.lambdaUpdate(ClothesOrder.class)
                .set(ClothesOrder::getPayOrderNo, payData.getPrepay_id())
                .set(ClothesOrder::getUpdatedTime, new Date())
                .eq(ClothesOrder::getId, orderInfo.getId())
                );
        return payData;
    }
@@ -439,9 +467,11 @@
     * @return
     */
    //图片上传路径
    public  static  final String IMG_UPLOAD_PATH="/mnt/sdc/webresource/blnka/wxcode";
            // todo 上线修改图片上传路径
    public  static  final String IMG_UPLOAD_PATH="/home/javaweb/webresource/upload/wxcode";
    public  String generateAcode(String scene,String path,String imgName,String width, Integer type){
        String urlPrefix="https://file.blnka.cn/blnka/wxcode";
            // todo 上线修改图片上传路径
        String urlPrefix="https://hcres.csxuncong.com/wxcode";
        String imgPath=IMG_UPLOAD_PATH+imgName;
        if(!FileUtil.exist(imgPath)){
@@ -471,7 +501,7 @@
            obj.set("is_hyaline", false);
            try {
                HttpResponse execute = HttpRequest.post(url).body(obj.toString(), "application/json").execute();
                log.error("微信返回值:{}", execute.body());
//                log.error("微信返回值:{}", execute.body());
                InputStream inputStream = execute.bodyStream();
                File file = new File(imgPath);
                FileUtil.writeFromStream(inputStream, file);
@@ -496,7 +526,7 @@
            }
        }
        log.debug("生成微信小程序码成功,路径:" + imgPath);
        return urlPrefix+"/"+imgName;
        return urlPrefix+imgName;
    }
    /**