|
|
@ -2,15 +2,13 @@ package cc.hiver.mall.controller; |
|
|
|
|
|
|
|
|
import cc.hiver.core.common.constant.SaleConstant; |
|
|
import cc.hiver.core.common.constant.SaleConstant; |
|
|
import cc.hiver.core.common.exception.HiverException; |
|
|
import cc.hiver.core.common.exception.HiverException; |
|
|
import cc.hiver.core.common.utils.BeanUtils; |
|
|
import cc.hiver.core.common.utils.*; |
|
|
import cc.hiver.core.common.utils.PageUtil; |
|
|
|
|
|
import cc.hiver.core.common.utils.ResultUtil; |
|
|
|
|
|
import cc.hiver.core.common.utils.StringUtils; |
|
|
|
|
|
import cc.hiver.core.common.vo.PageVo; |
|
|
import cc.hiver.core.common.vo.PageVo; |
|
|
import cc.hiver.core.common.vo.Result; |
|
|
import cc.hiver.core.common.vo.Result; |
|
|
import cc.hiver.core.common.vo.SearchVo; |
|
|
import cc.hiver.core.common.vo.SearchVo; |
|
|
import cc.hiver.core.entity.Worker; |
|
|
import cc.hiver.core.entity.Worker; |
|
|
import cc.hiver.core.service.WorkerService; |
|
|
import cc.hiver.core.service.WorkerService; |
|
|
|
|
|
import cc.hiver.file.manage.FileManageFactory; |
|
|
import cc.hiver.mall.common.constant.OrderConstant; |
|
|
import cc.hiver.mall.common.constant.OrderConstant; |
|
|
import cc.hiver.mall.deductlog.service.DeductLogService; |
|
|
import cc.hiver.mall.deductlog.service.DeductLogService; |
|
|
import cc.hiver.mall.entity.OrderXd; |
|
|
import cc.hiver.mall.entity.OrderXd; |
|
|
@ -21,11 +19,19 @@ import cc.hiver.mall.pojo.vo.OrderVO; |
|
|
import cc.hiver.mall.service.OrderService; |
|
|
import cc.hiver.mall.service.OrderService; |
|
|
import cc.hiver.mall.service.mybatis.ReturnSaleService; |
|
|
import cc.hiver.mall.service.mybatis.ReturnSaleService; |
|
|
import cc.hiver.mall.service.mybatis.SaleService; |
|
|
import cc.hiver.mall.service.mybatis.SaleService; |
|
|
|
|
|
import cc.hiver.mall.utils.ByteArrayMultipartFile; |
|
|
import cn.hutool.core.date.DateTime; |
|
|
import cn.hutool.core.date.DateTime; |
|
|
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
|
|
import com.google.gson.JsonObject; |
|
|
|
|
|
import com.google.gson.JsonParser; |
|
|
import io.swagger.annotations.Api; |
|
|
import io.swagger.annotations.Api; |
|
|
import io.swagger.annotations.ApiOperation; |
|
|
import io.swagger.annotations.ApiOperation; |
|
|
import io.swagger.annotations.ApiParam; |
|
|
import io.swagger.annotations.ApiParam; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import okhttp3.MediaType; |
|
|
|
|
|
import okhttp3.OkHttpClient; |
|
|
|
|
|
import okhttp3.Request; |
|
|
|
|
|
import okhttp3.Response; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.cache.annotation.CacheConfig; |
|
|
import org.springframework.cache.annotation.CacheConfig; |
|
|
import org.springframework.cache.annotation.Cacheable; |
|
|
import org.springframework.cache.annotation.Cacheable; |
|
|
@ -33,8 +39,15 @@ import org.springframework.dao.OptimisticLockingFailureException; |
|
|
import org.springframework.data.domain.Page; |
|
|
import org.springframework.data.domain.Page; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
import javax.validation.Valid; |
|
|
import javax.validation.Valid; |
|
|
|
|
|
import java.io.BufferedReader; |
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
import java.io.InputStream; |
|
|
|
|
|
import java.io.InputStreamReader; |
|
|
|
|
|
import java.net.HttpURLConnection; |
|
|
|
|
|
import java.net.URL; |
|
|
import java.util.Date; |
|
|
import java.util.Date; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
@ -68,6 +81,10 @@ public class OrderController { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private DeductLogService deductLogService; |
|
|
private DeductLogService deductLogService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private FileManageFactory fileManageFactory; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 该接口即可展示实时物流管理页面,可复用 |
|
|
* 该接口即可展示实时物流管理页面,可复用 |
|
|
*/ |
|
|
*/ |
|
|
@ -226,8 +243,6 @@ public class OrderController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 待抢单的订单类型 |
|
|
* 待抢单的订单类型 |
|
|
* <p> |
|
|
* <p> |
|
|
@ -358,8 +373,8 @@ public class OrderController { |
|
|
final String transCompanyId = sale.getTransCompany(); |
|
|
final String transCompanyId = sale.getTransCompany(); |
|
|
final String shopId = sale.getShopId(); |
|
|
final String shopId = sale.getShopId(); |
|
|
final String saleId = sale.getId(); |
|
|
final String saleId = sale.getId(); |
|
|
String transportType = sale.getTransportType(); |
|
|
final String transportType = sale.getTransportType(); |
|
|
deductLogService.updateRebateAmount(workId, transCompanyId, shopId, saleId,transportType); |
|
|
deductLogService.updateRebateAmount(workId, transCompanyId, shopId, saleId, transportType); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
@ -413,7 +428,7 @@ public class OrderController { |
|
|
/** |
|
|
/** |
|
|
* 转单接口 |
|
|
* 转单接口 |
|
|
* |
|
|
* |
|
|
* @param orderXd |
|
|
* @param orderVO |
|
|
* @return Result |
|
|
* @return Result |
|
|
* @author 王富康 |
|
|
* @author 王富康 |
|
|
* @date 2024/2/27 |
|
|
* @date 2024/2/27 |
|
|
@ -435,4 +450,87 @@ public class OrderController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 获取不限制的小程序码 |
|
|
|
|
|
* 参考链接:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/qr-code/getUnlimitedQRCode.html
|
|
|
|
|
|
* |
|
|
|
|
|
* @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式) |
|
|
|
|
|
* @param page 默认是主页,页面 page,例如 pages/index/index,根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面。scancode_time为系统保留参数,不允许配置 |
|
|
|
|
|
* @param envVersion 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"。默认是正式版。 |
|
|
|
|
|
* @return byte[] |
|
|
|
|
|
* @author 王富康 |
|
|
|
|
|
* @date 2024/9/14 |
|
|
|
|
|
*/ |
|
|
|
|
|
@RequestMapping(value = "/ow/getWechatQrcode", method = RequestMethod.POST) |
|
|
|
|
|
@ApiOperation("获取不限制的小程序码") |
|
|
|
|
|
public Result getWechatQrcodeByOkhttp3(String scene, String page, String envVersion) { |
|
|
|
|
|
// 非空校验
|
|
|
|
|
|
if (StringUtils.isEmpty(scene)) { |
|
|
|
|
|
return ResultUtil.error("参数错误"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取AccessToken地址
|
|
|
|
|
|
String wechatQrcodeAccessTokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET"; |
|
|
|
|
|
wechatQrcodeAccessTokenUrl = wechatQrcodeAccessTokenUrl.replace("APPID", "wx6d7d4fb58d1502db").replace("APPSECRET", "3a2c8cd00926764bbd12fd7361e01f1d"); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
final URL url = new URL(wechatQrcodeAccessTokenUrl); |
|
|
|
|
|
final HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
|
|
|
|
|
connection.setRequestMethod("GET"); |
|
|
|
|
|
connection.setRequestProperty("Accept", "application/json"); |
|
|
|
|
|
|
|
|
|
|
|
final int responseCode = connection.getResponseCode(); |
|
|
|
|
|
if (responseCode == HttpURLConnection.HTTP_OK) { |
|
|
|
|
|
final BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); |
|
|
|
|
|
String inputLine; |
|
|
|
|
|
final StringBuffer content = new StringBuffer(); |
|
|
|
|
|
while ((inputLine = in.readLine()) != null) { |
|
|
|
|
|
content.append(inputLine); |
|
|
|
|
|
} |
|
|
|
|
|
in.close(); |
|
|
|
|
|
connection.disconnect(); |
|
|
|
|
|
|
|
|
|
|
|
// 解析JSON数据
|
|
|
|
|
|
final JsonObject jsonObject = JsonParser.parseString(content.toString()).getAsJsonObject(); |
|
|
|
|
|
final String wxAccessToken = jsonObject.get("access_token").getAsString(); |
|
|
|
|
|
log.info("获取小程序码getQrtAccessToken成功:{}", wxAccessToken); |
|
|
|
|
|
//获取小程序码地址
|
|
|
|
|
|
final String wechatQrcodeUrl = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + wxAccessToken; |
|
|
|
|
|
final OkHttpClient client = new OkHttpClient(); |
|
|
|
|
|
final JSONObject jsonBody = new JSONObject(); |
|
|
|
|
|
jsonBody.set("scene", scene); |
|
|
|
|
|
jsonBody.set("page", page); |
|
|
|
|
|
jsonBody.set("env_version", envVersion); |
|
|
|
|
|
final okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(MediaType.parse("application/json"), jsonBody.toString()); |
|
|
|
|
|
final Request request = new Request.Builder() |
|
|
|
|
|
.url(wechatQrcodeUrl) |
|
|
|
|
|
.post(requestBody) |
|
|
|
|
|
.build(); |
|
|
|
|
|
try (Response response = client.newCall(request).execute()) { |
|
|
|
|
|
if (response.isSuccessful() && response.body() != null) { |
|
|
|
|
|
// 上传到服务器,返回地址。
|
|
|
|
|
|
final byte[] bytes = response.body().bytes(); |
|
|
|
|
|
final String contentType = "image/png"; // 文件类型
|
|
|
|
|
|
// 上传至第三方云服务或服务器
|
|
|
|
|
|
final MultipartFile multipartFile = new ByteArrayMultipartFile(bytes, "qrcode.png", contentType); |
|
|
|
|
|
final String fKey = CommonUtil.renamePic(multipartFile.getOriginalFilename()); |
|
|
|
|
|
final InputStream inputStream = multipartFile.getInputStream(); |
|
|
|
|
|
final String result = fileManageFactory.getFileManage(null).inputStreamUpload(inputStream, fKey, multipartFile); |
|
|
|
|
|
return new ResultUtil<String>().setData(result); |
|
|
|
|
|
} else { |
|
|
|
|
|
log.error("【小程序码】Failed response, status code: {}", response.code()); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
log.error("【小程序码】Request failed", e); |
|
|
|
|
|
return ResultUtil.error("获取小程序码失败!"); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
System.err.println("请求失败:" + responseCode); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|