forked from qmpaas/leadshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
新增:获取电子面单发货 新增:开屏广告可设置每X天显示 新增:商品参数 新增:商品副标题 新增:公众号/小程序商城跳转其他小程序和超链接 优化:后台编辑新商品信息的步骤逻辑优化 优化:后台编辑商品详情,可从素材库多选图片上传 优化:待发货订单支持按单个商品或整个订单申请仅退款,并支持退运费 修复:单规格商品手机端显示空白规格问题 修复:任务-完善个人信息后引导内容仍然显示问题 修复:商品评价时间,后台和手机端不一致问题
- Loading branch information
Showing
268 changed files
with
2,616 additions
and
683 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
namespace leadmall\api; | ||
|
||
use leadmall\Map; | ||
use goods\api\ArgsController as GoodsargsModules; | ||
|
||
class GoodsargsController extends GoodsargsModules implements Map | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
|
||
namespace leadmall\api; | ||
|
||
|
||
use leadmall\Map; | ||
use setting\api\WaybillController as WaybillModules; | ||
|
||
class WaybillController extends WaybillModules implements Map | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
<?php | ||
/** | ||
* @copyright ©2020 浙江禾成云计算有限公司 | ||
* Created by PhpStorm. | ||
* User: Andy - 阿德 [email protected] | ||
* Date: 2021/6/29 | ||
* Time: 17:54 | ||
*/ | ||
|
||
namespace app\components; | ||
|
||
use app\components\express\BaseExpress; | ||
use GuzzleHttp\Exception\TransferException; | ||
use order\models\Order; | ||
|
||
class Waybill extends BaseExpress | ||
{ | ||
//测试地址 上线需更换 | ||
protected $url = 'https://kop.kuaidihelp.com/test'; | ||
|
||
/**@var \setting\models\Waybill $waybill 电子面单设置*/ | ||
protected $waybill; | ||
/**@var Order $order 订单*/ | ||
protected $order; | ||
/**@var string $orderSn 订单编号,必须唯一 */ | ||
protected $orderSn; | ||
/**@var string $shipperType 快递公司标识符,如:zt 。*/ | ||
protected $shipperType; | ||
/**@var string $siteFlag 快递网点名称(申通必填)*/ | ||
protected $siteFlag; | ||
/**@var int $payType 支付方式 :1-寄方支付,2-收方支付,3-月结(支持EMS、邮政快递包裹、邮政标准快递和顺丰速运)*/ | ||
protected $payType = 1; | ||
/**@var string $tradeName 商品名称(最多50个字符)*/ | ||
protected $tradeName; | ||
/**@var string $bName 寄件方信息列表*/ | ||
protected $bName; | ||
/**@var $bMobile string 手机号码*/ | ||
protected $bMobile; | ||
/**@var string $bProvince 寄件方所在省名称,如果所在省有省字,则不能略 */ | ||
protected $bProvince; | ||
/**@var string $bCity 寄件方所在省名称,如果所在省有省字,则不能略 */ | ||
protected $bCity; | ||
/**@var string $bDistrict 寄件方所在地区(区/县/镇) */ | ||
protected $bDistrict; | ||
/**@var string $bAddress 寄件方地址 */ | ||
protected $bAddress; | ||
|
||
/**@var string $name 收件方信息列表*/ | ||
protected $name; | ||
/**@var $mobile string 收件方手机号码*/ | ||
protected $mobile; | ||
/**@var string $province 收件方所在省名称,如果所在省有省字,则不能略 */ | ||
protected $province; | ||
/**@var string $city 收件方所在省名称,如果所在省有省字,则不能略 */ | ||
protected $city; | ||
/**@var string $district 收件方所在地区(区/县/镇) */ | ||
protected $district; | ||
/**@var string $address 收件方地址 */ | ||
protected $address; | ||
|
||
/**@var string $customerName 大客户账号*/ | ||
protected $customerName; | ||
/**@var string $customerPassword 大客户密码*/ | ||
protected $customerPassword; | ||
|
||
public function wrap($param) | ||
{ | ||
if (!isset($param['order_sn']) || !isset($param['waybill_id'])) { | ||
Error('参数不完整'); | ||
} | ||
$this->order = Order::find()->with(['buyer', 'freight', 'goods'])->where(['order_sn' => $param['order_sn']])->one(); | ||
if (!$this->order) { | ||
Error('订单不存在'); | ||
} | ||
$this->waybill = \setting\models\Waybill::findOne(['id' => $param['waybill_id'], 'is_deleted' => 0]); | ||
if (!$this->waybill) { | ||
Error('电子面单未配置'); | ||
} | ||
$this->orderSn = $this->order->order_sn; | ||
if ($this->shipperType == 'sto') { | ||
if (!isset($param['site_flag'])) { | ||
Error('快递网点名称(申通必填)'); | ||
} else { | ||
$this->siteFlag = $param['site_flag']; | ||
} | ||
} | ||
$goodsNameList = $this->order->goods; | ||
$goodsName = ''; | ||
foreach ($goodsNameList as $v) { | ||
$goodsName .= $v['goods_name'] . ';'; | ||
} | ||
$goodsName = rtrim($goodsName, ';'); | ||
if (mb_strlen($goodsName) > 50) { | ||
$goodsName = mb_substr($goodsName, 0, 47); | ||
$goodsName .= '...'; | ||
} | ||
$this->tradeName = $goodsName; | ||
//寄件人信息 | ||
$this->bName = $this->waybill->name; | ||
$this->bMobile = $this->waybill->mobile; | ||
$this->bProvince = $this->waybill->province; | ||
$this->bCity = $this->waybill->city; | ||
$this->bDistrict = $this->waybill->district; | ||
$this->bAddress = $this->waybill->address; | ||
$this->shipperType = $this->waybill->code; | ||
|
||
//收件人信息 | ||
$this->name = $this->order->buyer->name; | ||
$this->mobile = $this->order->buyer->mobile; | ||
$this->province = $this->order->buyer->province; | ||
$this->city = $this->order->buyer->city; | ||
$this->district = $this->order->buyer->district; | ||
$this->address = $this->order->buyer->address; | ||
|
||
//大客户账号密码 | ||
$this->customerName = $this->waybill->customer_name ?? ''; | ||
$this->customerPassword = $this->waybill->customer_password ?? ''; | ||
} | ||
|
||
public function getResult() | ||
{ | ||
$params = [ | ||
'order_id' => $this->orderSn, | ||
'shipper_type' => $this->shipperType, | ||
'pay_type' => $this->payType, | ||
'trade_name' => $this->tradeName, | ||
'sender' => [ | ||
'name' => $this->bName, | ||
'mobile' => $this->bMobile, | ||
'province' => $this->bProvince, | ||
'city' => $this->bCity, | ||
'district' => $this->bDistrict, | ||
'address' => $this->bAddress | ||
], | ||
'recipient' => [ | ||
'name' => $this->name, | ||
'mobile' => $this->mobile, | ||
'province' => $this->province, | ||
'city' => $this->city, | ||
'district' => $this->district, | ||
'address' => $this->address | ||
], | ||
'customer_name' => $this->customerName, | ||
'customer_password' => $this->customerPassword | ||
]; | ||
$config = $this->getConfig(); | ||
if (!isset($config['app_id']) || empty($config['app_key'])) { | ||
Error('请配置快宝开放平台'); | ||
} | ||
$header = [ | ||
'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8', | ||
]; | ||
$method = 'account.waybill.get'; | ||
$time = time(); | ||
$body = [ | ||
"app_id" => $config['app_id'], | ||
"method" => $method, | ||
"sign" => md5($config['app_id'] . $method . $time . $config['app_key']), | ||
"ts" => $time, | ||
"data" => json_encode($params) | ||
]; | ||
try { | ||
return $this->post($this->url, $body, $header); | ||
} catch (TransferException $e) { | ||
$httpCode = $e->getResponse()->getStatusCode(); | ||
$headers = $e->getResponse()->getHeaders(); | ||
$msg = [ | ||
'code' => $httpCode, | ||
'header' => $headers, | ||
'msg' => '"参数名错误 或 其他错误"', | ||
]; | ||
$this->returnError($msg); | ||
} catch (\Exception $e) { | ||
$this->returnError($e->getMessage()); | ||
} | ||
} | ||
|
||
public function parseResult($content) | ||
{ | ||
return $content; | ||
} | ||
|
||
protected function returnError($msg) | ||
{ | ||
\Yii::$app->response->data = [ | ||
'code' => -1, | ||
'message' => $msg | ||
]; | ||
\Yii::$app->end(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
|
||
namespace app\components; | ||
|
||
use GuzzleHttp\Exception\TransferException; | ||
|
||
class WaybillPrint extends Waybill | ||
{ | ||
protected $url = 'https://kop.kuaidihelp.com/api'; | ||
|
||
/**@var string $agentId 目标云打印机的访问密钥*/ | ||
protected $agentId; | ||
/**@var int $printType 打印类型,1:仅生成底单,jpg格式; 2:仅打印; 3:打印并生成jpg格式底单; 7:仅生成底单,pdf格式;默认为3*/ | ||
protected $printType = 3; | ||
|
||
public function getResult() | ||
{ | ||
$params = [ | ||
'print_type' => $this->printType, | ||
'print_data' => [ | ||
[ | ||
'tid' => $this->orderSn, | ||
'waybill_code' => '', | ||
'cp_code' => $this->shipperType, | ||
'sender' => [ | ||
'name' => $this->bName, | ||
'mobile' => $this->bMobile, | ||
'phone' => $this->bMobile, | ||
'address' => [ | ||
'province' => $this->bProvince, | ||
'city' => $this->bCity, | ||
'district' => $this->bDistrict, | ||
'detail' => $this->bAddress | ||
] | ||
], | ||
'recipient' => [ | ||
'name' => $this->name, | ||
'mobile' => $this->mobile, | ||
'phone' => $this->mobile, | ||
'address' => [ | ||
'province' => $this->province, | ||
'city' => $this->city, | ||
'district' => $this->district, | ||
'detail' => $this->address | ||
] | ||
], | ||
'routing_info' => [], | ||
'goods_name' => $this->tradeName | ||
] | ||
], | ||
]; | ||
$config = $this->getConfig(); | ||
if (!isset($config['app_id']) || empty($config['app_key']) || empty($config['agent_id'])) { | ||
Error('请配置快宝开放平台'); | ||
} | ||
$params['agent_id'] = $config['agent_id']; | ||
$header = [ | ||
'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8', | ||
]; | ||
$method = 'cloud.print.waybill'; | ||
$time = time(); | ||
$body = [ | ||
"app_id" => $config['app_id'], | ||
"method" => $method, | ||
"sign" => md5($config['app_id'] . $method . $time . $config['app_key']), | ||
"ts" => $time, | ||
"data" => json_encode($params) | ||
]; | ||
try { | ||
return $this->post($this->url, $body, $header); | ||
} catch (TransferException $e) { | ||
$httpCode = $e->getResponse()->getStatusCode(); | ||
$headers = $e->getResponse()->getHeaders(); | ||
$msg = [ | ||
'code' => $httpCode, | ||
'header' => $headers, | ||
'msg' => '"参数名错误 或 其他错误"', | ||
]; | ||
$this->returnError($msg); | ||
} catch (\Exception $e) { | ||
$this->returnError($e->getMessage()); | ||
} | ||
} | ||
|
||
public function parseResult($content) | ||
{ | ||
if ($content['code'] == 221009) { | ||
Error($content['data'][$this->orderSn]['message']); | ||
} | ||
if ($content['code'] != 0) { | ||
Error($content['msg']); | ||
} | ||
if ($content['data'][$this->orderSn]['status'] == 'success') { | ||
return [ | ||
'freight_sn' => $content['data'][$this->orderSn]['task_info']['waybill_code'] ?? '', | ||
'preview_image' => $content['data'][$this->orderSn]['preview_image'] ?? '' | ||
]; | ||
} elseif ($content['data'][$this->orderSn]['status'] == 'failure') { | ||
if ($content['data'][$this->orderSn]['message'] == '已有相同tid的任务在执行,请30秒后重试') { | ||
Error('频繁获取电子面单,请30秒后重试'); | ||
} | ||
Error($content['data'][$this->orderSn]['message']); | ||
} else { | ||
Error('获取电子面单出错'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.