| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace common\components\delivery\platform\shunfeng;
- /**
- * Class Shop
- * 门店接口实现
- */
- class Shop extends Shunfeng
- {
- /**
- * 获取店铺账户余额
- *
- * 获取当前店铺储值卡/预付费余额
- *
- * 文档参考:https://openic.sf-express.com/open/api/external/getshopaccountbalance
- *
- * @return array 返回格式:['success' => true/false, 'balance' => 0, 'reserved_amount' => 0,
- * 'withdraw_amount' => 0, 'supplier_balance' => 0, 'message' => '']
- * balance: 店铺账户余额,单位:分
- * reserved_amount: 预留余额,单位:分
- * withdraw_amount: 实际可提现余额,单位:分
- * supplier_balance: 商家账户余额,单位:分(仅当传入为链店铺ID时返回)
- */
- public function getShopAccountBalance()
- {
- // 构建请求参数
- $businessData = [
- 'push_time' => time(),
- ];
-
- // 调用httpRequest方法发送请求
- $response = $this->httpRequest('getshopaccountbalance', $businessData);
-
- // 检查API响应
- if (isset($response['error_code']) && $response['error_code'] == 0) {
- return [
- 'success' => true,
- 'balance' => $response['result']['balance'],
- 'reserved_amount' => $response['result']['reserved_amount'],
- 'withdraw_amount' => $response['result']['withdraw_amount'],
- 'pay_amount' => $response['result']['pay_amount'],
- 'message' => '查询余额成功',
- ];
- }
-
- return [
- 'success' => false,
- 'balance' => 0,
- 'reserved_amount' => 0,
- 'withdraw_amount' => 0,
- 'supplier_balance' => 0,
- 'message' => $response['error_msg'] ?? '查询余额失败',
- ];
- }
- /**
- * 获取店铺信息
- *
- * 2025/2/17更新,返回参数更新,支持返回物流产品,详见logistic_type_list
- * 开发者可通过该接⼝获取到店铺的基础信息(非连锁店铺可以额外获得等级信息和补贴信息)
- *
- * @param string $shopId 店铺ID
- * @param int $shopType 店铺ID类型 1:顺丰店铺ID 2:接⼊⽅店铺ID
- * @return mixed
- */
- public function getShopInfo($shopId, $shopType = 1)
- {
- $params = [
- 'shop_id' => $shopId,
- 'shop_type' => $shopType,
- 'push_time' => time()
- ];
- $response = $this->httpRequest('getshopinfo', $params);
- // 检查API响应
- if (isset($response['error_code']) && $response['error_code'] == 0) {
- return [
- 'success' => true,
- 'shop_info' => $response['result']['shop_info'] ?? [],
- 'message' => '获取店铺信息成功',
- ];
- }
- return [
- 'success' => false,
- 'shop_info' => [],
- 'message' => $response['error_msg'] ?? '获取店铺信息失败',
- ];
- }
- }
|