diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 5f3d514e..2a093948 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -15,8 +15,10 @@ namespace app\api\controller; use app\api\model\{Goods as GoodsModel, Store as StoreModel}; use app\api\model\Region; 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\UploadFile as UploadFileModel; +use app\common\model\wxapp\Setting as WxappSettingModel; use app\common\service\qrcode\Goods as GoodsPoster; use cores\exception\BaseException; use think\db\exception\DbException; @@ -97,7 +99,6 @@ class Goods extends Controller 'state' => "无货", 'goods_name' => $goods['goods_name'], 'goods_id' => $goods['goods_id'], - 'promise_info' => "预计".(GoodsDeliveryTime::data()[$goods['delivery_time']] ?? "72小时")."内发货", ]; $return[] = $data; continue; @@ -111,7 +112,6 @@ class Goods extends Controller $data = $suning->shoppingCartPrice([$goods->toArray()], $city->sn_code, $district->sn_code); $data['goods_name'] = $goods['goods_name']; $data['goods_id'] = $goods['goods_id']; - $data['promise_info'] = "预计".(GoodsDeliveryTime::data()[$goods['delivery_time']] ?? "72小时")."内发货"; break; case 'jd': case 'jd1': @@ -134,7 +134,6 @@ class Goods extends Controller 'state' => $res, 'goods_name' => $goods['goods_name'], 'goods_id' => $goods['goods_id'], - 'promise_info' => $ret['promiseInfo'] ?? "预计72小时内发货", ]; break; default: @@ -145,7 +144,6 @@ class Goods extends Controller 'state' => $res, 'goods_name' => $goods['goods_name'], 'goods_id' => $goods['goods_id'], - 'promise_info' => "预计".(GoodsDeliveryTime::data()[$goods['delivery_time']] ?? "72小时")."内发货", ]; break; @@ -387,5 +385,22 @@ class Goods extends Controller 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]); + } }