wang hou sheng 7 months ago
parent 6ef19f25db
commit 0bb80ca2d5
  1. 19
      app/api/controller/Goods.php
  2. 8
      app/api/controller/StoreKeeper.php
  3. 8
      app/store/controller/Order.php

@ -15,8 +15,10 @@ namespace app\api\controller;
use app\api\model\{Goods as GoodsModel, Store as StoreModel}; use app\api\model\{Goods as GoodsModel, Store as StoreModel};
use app\api\model\Region; use app\api\model\Region;
use app\api\service\{Goods as GoodsService, User as UserService}; use app\api\service\{Goods as GoodsService, User as UserService};
use app\common\library\wechat\ShortLink;
use app\common\model\GoodsImage as GoodsImageModel; use app\common\model\GoodsImage as GoodsImageModel;
use app\common\model\UploadFile as UploadFileModel; use app\common\model\UploadFile as UploadFileModel;
use app\common\model\wxapp\Setting as WxappSettingModel;
use app\common\service\qrcode\Goods as GoodsPoster; use app\common\service\qrcode\Goods as GoodsPoster;
use cores\exception\BaseException; use cores\exception\BaseException;
use think\db\exception\DbException; use think\db\exception\DbException;
@ -383,5 +385,22 @@ class Goods extends Controller
return $this->renderSuccess(['imageUrl' => $Qrcode->getImage()]); return $this->renderSuccess(['imageUrl' => $Qrcode->getImage()]);
} }
public function shortUrl(): Json
{
$page_url = $this->request->post('page_url');
if (empty($page_url)) {
return $this->renderError('缺少参数page_url');
}
$page_title = $this->request->post('page_title');
if (empty($page_title)) {
return $this->renderError('缺少参数page_title');
}
$store_id = GoodsModel::$storeId;
$wxConfig = WxappSettingModel::getConfigBasic($store_id);
// 请求api获取短连接
$link_obj = new ShortLink($wxConfig['app_id'], $wxConfig['app_secret']);
$url = $link_obj->shortUrl($page_url, $page_title);
return $this->renderSuccess(['url' => $url]);
}
} }

@ -13,9 +13,7 @@ declare (strict_types=1);
namespace app\api\controller; namespace app\api\controller;
use app\common\enum\RecoveryStatusEnum; use app\common\enum\RecoveryStatusEnum;
use app\common\library\wechat\ShortLink;
use app\common\model\UploadFile; use app\common\model\UploadFile;
use app\common\model\wxapp\Setting as WxappSettingModel;
use app\store\model\Article as ArticleModel; use app\store\model\Article as ArticleModel;
use app\store\model\article\Category as CategoryModel; use app\store\model\article\Category as CategoryModel;
use app\store\model\dealer\Order as DealerOrderModel; use app\store\model\dealer\Order as DealerOrderModel;
@ -195,11 +193,6 @@ class StoreKeeper extends Controller
return $this->renderSuccess(compact('list')); return $this->renderSuccess(compact('list'));
} else { } else {
$model = new OrderModel; $model = new OrderModel;
$store_id = OrderModel::$storeId;
// 小程序配置信息
$wxConfig = WxappSettingModel::getConfigBasic($store_id);
// 请求api获取短连接
$link_obj = new ShortLink($wxConfig['app_id'], $wxConfig['app_secret']);
$list = $model->getNewList($params); $list = $model->getNewList($params);
if (!empty($list['data'])) { if (!empty($list['data'])) {
foreach ($list['data'] as $key => $value) { foreach ($list['data'] as $key => $value) {
@ -227,7 +220,6 @@ class StoreKeeper extends Controller
$copy_text .= "单价:{$good['goods_price']}\n"; $copy_text .= "单价:{$good['goods_price']}\n";
$copy_text .= "数量:{$good['total_num']}\n"; $copy_text .= "数量:{$good['total_num']}\n";
$copy_text .= "总价:{$good['total_price']}\n"; $copy_text .= "总价:{$good['total_price']}\n";
$copy_text .= "商品链接:" . $link_obj->shortUrl("/pages/goods/detail?goodsId=" . $good['goods_id'], '商品详情');
$copy_text .= "\n"; $copy_text .= "\n";
} }
if (!empty($value['address'])) { if (!empty($value['address'])) {

@ -12,8 +12,6 @@ declare (strict_types=1);
namespace app\store\controller; namespace app\store\controller;
use app\common\library\wechat\ShortLink;
use app\common\model\wxapp\Setting as WxappSettingModel;
use app\store\model\Order as OrderModel; use app\store\model\Order as OrderModel;
use think\response\Json; use think\response\Json;
@ -35,11 +33,6 @@ class Order extends Controller
$model = new OrderModel; $model = new OrderModel;
$result = $model->getList($this->request->param()); $result = $model->getList($this->request->param());
$data = $result->items(); $data = $result->items();
$store_id = OrderModel::$storeId;
// 小程序配置信息
$wxConfig = WxappSettingModel::getConfigBasic($store_id);
// 请求api获取短连接
$link_obj = new ShortLink($wxConfig['app_id'], $wxConfig['app_secret']);
if (!empty($data)) { if (!empty($data)) {
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$data[$key]['address_match_text'] = '--'; $data[$key]['address_match_text'] = '--';
@ -52,7 +45,6 @@ class Order extends Controller
$copy_text .= "单价:{$good['goods_price']}\n"; $copy_text .= "单价:{$good['goods_price']}\n";
$copy_text .= "数量:{$good['total_num']}\n"; $copy_text .= "数量:{$good['total_num']}\n";
$copy_text .= "总价:{$good['total_price']}\n"; $copy_text .= "总价:{$good['total_price']}\n";
$copy_text .= "商品链接:" . $link_obj->shortUrl("pages/goods/detail?goodsId=" . $good['goods_id'], '商品详情');
$copy_text .= "\n"; $copy_text .= "\n";
} }
if (!empty($value['address'])) { if (!empty($value['address'])) {

Loading…
Cancel
Save