初始上传
This commit is contained in:
24
addon/weapp/event/BlindboxOrderPay.php
Executable file
24
addon/weapp/event/BlindboxOrderPay.php
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\event;
|
||||
|
||||
use app\model\system\Cron;
|
||||
|
||||
/**
|
||||
* 礼品卡订单支付后
|
||||
*/
|
||||
class BlindboxOrderPay
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
return (new Cron())->addCron(1, 0, "小程序虚拟发货", "WeappVirtualDelivery", time() + 60, $param['out_trade_no']);
|
||||
}
|
||||
}
|
||||
30
addon/weapp/event/DecryptData.php
Executable file
30
addon/weapp/event/DecryptData.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\event;
|
||||
|
||||
use addon\weapp\model\Weapp;
|
||||
|
||||
/**
|
||||
* 开放数据解密
|
||||
*/
|
||||
class DecryptData
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle($param = [])
|
||||
{
|
||||
if ($param['app_type'] == 'weapp') {
|
||||
$weapp = new Weapp($param['site_id']);
|
||||
return $weapp->decryptData($param);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
addon/weapp/event/GiftCardOrderPay.php
Executable file
24
addon/weapp/event/GiftCardOrderPay.php
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\event;
|
||||
|
||||
use app\model\system\Cron;
|
||||
|
||||
/**
|
||||
* 礼品卡订单支付后
|
||||
*/
|
||||
class GiftCardOrderPay
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
return (new Cron())->addCron(1, 0, "小程序虚拟发货", "WeappVirtualDelivery", time() + 60, $param['out_trade_no']);
|
||||
}
|
||||
}
|
||||
25
addon/weapp/event/Install.php
Executable file
25
addon/weapp/event/Install.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
24
addon/weapp/event/MemberLevelOrderPay.php
Executable file
24
addon/weapp/event/MemberLevelOrderPay.php
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\event;
|
||||
|
||||
use app\model\system\Cron;
|
||||
|
||||
/**
|
||||
* 礼品卡订单支付后
|
||||
*/
|
||||
class MemberLevelOrderPay
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
return (new Cron())->addCron(1, 0, "小程序虚拟发货", "WeappVirtualDelivery", time() + 60, $param['out_trade_no']);
|
||||
}
|
||||
}
|
||||
24
addon/weapp/event/MemberRechargeOrderPay.php
Executable file
24
addon/weapp/event/MemberRechargeOrderPay.php
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\event;
|
||||
|
||||
use app\model\system\Cron;
|
||||
|
||||
/**
|
||||
* 充值订单完成后
|
||||
*/
|
||||
class MemberRechargeOrderPay
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
return (new Cron())->addCron(1, 0, "小程序虚拟发货", "WeappVirtualDelivery", time() + 60, $param['out_trade_no']);
|
||||
}
|
||||
}
|
||||
27
addon/weapp/event/OrderDeliveryAfter.php
Executable file
27
addon/weapp/event/OrderDeliveryAfter.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\event;
|
||||
|
||||
use app\model\system\Cron;
|
||||
|
||||
/**
|
||||
* 订单发货完成,小程序发货信息录入
|
||||
*/
|
||||
class OrderDeliveryAfter
|
||||
{
|
||||
public function handle($data)
|
||||
{
|
||||
//支付后立即调用发货接口,微信会提示订单不存在,所以延迟一分钟执行,如果是
|
||||
//{"errcode":10060001,"errmsg":"支付单不存在 rid: 66235dcf-4803e8cf-5c30a69e"}
|
||||
//如果是物流发货和同城配送不会有问题,自提订单和虚拟订单有可能支付后就立即发货
|
||||
(new Cron())->addCron(1, 0, "订单发货后小程序发货", "OrderDeliveryAfterWeappDelivery", time() + 60, $data[ 'order_id' ]);
|
||||
}
|
||||
}
|
||||
175
addon/weapp/event/OrderDeliveryAfterWeappDelivery.php
Executable file
175
addon/weapp/event/OrderDeliveryAfterWeappDelivery.php
Executable file
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\event;
|
||||
|
||||
use addon\weapp\model\Weapp;
|
||||
use app\model\order\Order;
|
||||
use app\model\shop\Shop as ShopModel;
|
||||
use app\dict\order\OrderDict;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 订单发货完成,小程序发货信息录入
|
||||
*/
|
||||
class OrderDeliveryAfterWeappDelivery
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
try{
|
||||
//订单信息
|
||||
$order_model = new Order();
|
||||
$filed = 'o.order_id,o.site_id,o.order_type,o.out_trade_no,o.pay_type,o.mobile,o.promotion_type,m.weapp_openid';
|
||||
$join = [
|
||||
[ 'member m', 'o.member_id=m.member_id', 'left' ]
|
||||
];
|
||||
$order_info = model('order')->getInfo([ [ 'order_id', '=', $param[ 'relate_id' ] ] ], $filed, 'o', $join);
|
||||
if (empty($order_info)) return $order_model->success();
|
||||
if ($order_info[ 'pay_type' ] != 'wechatpay') return $order_model->success();
|
||||
|
||||
// 检测微信小程序是否已开通发货信息管理服务
|
||||
$weapp_model = new Weapp($order_info[ 'site_id' ]);
|
||||
$is_trade_managed = $weapp_model->orderShippingIsTradeManaged()['data'];
|
||||
if (!$is_trade_managed) return $weapp_model->success();
|
||||
|
||||
//商家信息
|
||||
$shop_model = new ShopModel();
|
||||
$shop_info = $shop_model->getShopInfo([ [ 'site_id', '=', $order_info[ 'site_id' ] ] ], '')[ 'data' ];
|
||||
|
||||
//物流模式和发货方式
|
||||
$logistics_type_config = [
|
||||
OrderDict::express => Weapp::LOGISTICS_TYPE_EXPRESS,
|
||||
OrderDict::local => Weapp::LOGISTICS_TYPE_LOCAL,
|
||||
OrderDict::store => Weapp::LOGISTICS_TYPE_STORE,
|
||||
OrderDict::virtual => Weapp::LOGISTICS_TYPE_VIRTUAL,
|
||||
];
|
||||
$logistics_type = $logistics_type_config[$order_info['order_type']];
|
||||
$delivery_mode = $order_info['order_type'] == OrderDict::express ? Weapp::SPLIT_DELIVERY : Weapp::UNIFIED_DELIVERY;
|
||||
|
||||
//小程序物流公司
|
||||
$delivery_list = [];
|
||||
if ($logistics_type == OrderDict::express) {
|
||||
$delivery_list = $weapp_model->orderShippingGetDeliveryList()[ 'data' ];
|
||||
}
|
||||
//订单商品
|
||||
$order_goods_field = 'order_goods_id,sku_name,num,delivery_no,delivery_status';
|
||||
$order_goods_list = $order_model->getOrderGoodsList([
|
||||
[ 'order_id', '=', $order_info[ 'order_id' ] ]
|
||||
], $order_goods_field, 'order_goods_id asc')[ 'data' ];
|
||||
$order_goods_list = array_column($order_goods_list, null, 'order_goods_id');
|
||||
//寄件人联系方式
|
||||
$consignor_contact = $this->mobileShow($shop_info[ 'mobile' ]);
|
||||
//收件人联系方式
|
||||
$receiver_contact = $this->mobileShow($order_info[ 'mobile' ]);
|
||||
//组装小程序发货信息
|
||||
$shipping_list = [];
|
||||
$delivery_goods_count = 0;
|
||||
$is_all_delivered = true;
|
||||
if ($logistics_type == OrderDict::express) {
|
||||
$package_list = model('express_delivery_package')->getList([
|
||||
[ 'order_id', '=', $order_info[ 'order_id' ] ],
|
||||
], '*');
|
||||
foreach($package_list as $package_info){
|
||||
//商品信息
|
||||
$order_goods_ids = explode(',', $package_info['order_goods_id_array']);
|
||||
$item_desc = [];
|
||||
foreach($order_goods_ids as $order_goods_id){
|
||||
$order_goods_info = $order_goods_list[$order_goods_id];
|
||||
$item_desc_text = $order_goods_info['sku_name'].'*'.$order_goods_info['num'];
|
||||
$item_desc[] = $item_desc_text;
|
||||
$delivery_goods_count ++;
|
||||
}
|
||||
//物流公司
|
||||
$express_company = '';
|
||||
if (!empty($package_info[ 'express_company_name' ]) && !empty($delivery_list)) {
|
||||
$delivery_index = array_search($package_info[ 'express_company_name' ], array_column($delivery_list, 'delivery_name'));
|
||||
if ($delivery_index === false) continue;
|
||||
$express_company = $delivery_list[ $delivery_index ][ 'delivery_id' ];
|
||||
}
|
||||
if(empty($express_company)) continue;
|
||||
//数据结构
|
||||
$item = [
|
||||
'tracking_no' => $package_info[ 'delivery_no' ], // 物流单号,物流快递发货时必填,示例值: 323244567777 字符字节限制: [1, 128]
|
||||
'express_company' => $express_company, // 物流公司编码,快递公司ID,参见「查询物流公司编码列表」,物流快递发货时必填, 示例值: DHL 字符字节限制: [1, 128]
|
||||
'item_desc' => $weapp_model->handleOrderShippingItemDesc($item_desc), // 商品信息,例如:微信红包抱枕*1个,限120个字以内
|
||||
'contact' => [
|
||||
'consignor_contact' => $consignor_contact,
|
||||
'receiver_contact' => $receiver_contact,
|
||||
]
|
||||
];
|
||||
//最多只能有9个包裹
|
||||
if(count($shipping_list) < 9){
|
||||
$shipping_list[] = $item;
|
||||
}
|
||||
}
|
||||
if(empty($shipping_list)){
|
||||
$logistics_type = Weapp::LOGISTICS_TYPE_LOCAL;
|
||||
$delivery_mode = Weapp::UNIFIED_DELIVERY;
|
||||
}
|
||||
if($delivery_goods_count < count($order_goods_list)){
|
||||
$is_all_delivered = false;
|
||||
}
|
||||
}
|
||||
//统一发货的发货信息
|
||||
if($delivery_mode == Weapp::UNIFIED_DELIVERY){
|
||||
$item_desc = [];
|
||||
foreach($order_goods_list as $order_goods_info){
|
||||
$item_desc_text = $order_goods_info['sku_name'].'*'.$order_goods_info['num'];
|
||||
$item_desc[] = $item_desc_text;
|
||||
}
|
||||
$shipping_list[] = [
|
||||
'tracking_no' => '', // 物流单号,物流快递发货时必填,示例值: 323244567777 字符字节限制: [1, 128]
|
||||
'express_company' => '', // 物流公司编码,快递公司ID,参见「查询物流公司编码列表」,物流快递发货时必填, 示例值: DHL 字符字节限制: [1, 128]
|
||||
'item_desc' => $weapp_model->handleOrderShippingItemDesc($item_desc), // 商品信息,例如:微信红包抱枕*1个,限120个字以内
|
||||
'contact' => [
|
||||
'consignor_contact' => $consignor_contact,
|
||||
'receiver_contact' => $receiver_contact,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$param = [
|
||||
'site_id' => $order_info['site_id'],
|
||||
'out_trade_no' => $order_info['out_trade_no'],
|
||||
'logistics_type' => $logistics_type,
|
||||
'delivery_mode' => $delivery_mode,
|
||||
'shipping_list' => $shipping_list,
|
||||
'weapp_openid' => $order_info[ 'weapp_openid' ],
|
||||
'is_all_delivered' => $is_all_delivered,
|
||||
];
|
||||
$res = $weapp_model->orderShippingUploadShippingInfo($param);
|
||||
//如果是预售,尾款也需要同步发货信息
|
||||
if($order_info['promotion_type'] == 'presale'){
|
||||
$param['out_trade_no'] = $order_info['out_trade_no_2'];
|
||||
$res = $weapp_model->orderShippingUploadShippingInfo($param);
|
||||
}
|
||||
Log::write('小程序发货结果' . json_encode($res, JSON_UNESCAPED_UNICODE));
|
||||
//dd($param,$res);
|
||||
return $res;
|
||||
}catch(\Exception $e){
|
||||
Log::write('小程序发货错误' . json_encode([
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'message' => $e->getMessage(),
|
||||
], JSON_UNESCAPED_UNICODE));
|
||||
//dd($e->getFile(),$e->getLine(),$e->getMessage());
|
||||
return error(-1, '小程序上传发货信息错误,'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 寄件人和收件人联系方式,采用掩码传输,最后4位数字不能打掩码 示例值: `189****1234, 021-****1234, ****1234, 0**2-***1234, 0**2-******23-10, ****123-8008` 值限制: 0 ≤ value ≤ 1024
|
||||
protected function mobileShow($mobile)
|
||||
{
|
||||
if($mobile){
|
||||
$mobile =substr($mobile, 0, 3) . '****' . substr($mobile, 7);
|
||||
}
|
||||
return $mobile;
|
||||
}
|
||||
}
|
||||
59
addon/weapp/event/OrderTakeDeliveryAfter.php
Executable file
59
addon/weapp/event/OrderTakeDeliveryAfter.php
Executable file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\event;
|
||||
|
||||
|
||||
use addon\weapp\model\Weapp;
|
||||
use addon\wechatpay\model\Config as WechatPayModel;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 订单收货,小程序确认收货提醒
|
||||
*/
|
||||
class OrderTakeDeliveryAfter
|
||||
{
|
||||
public function handle($data)
|
||||
{
|
||||
//通知应该是在用户实际收货后去提醒,正确的做法是通过物流信息获取到用户已收货,然后发出提醒。但是目前做不到这一点,只能是后台商家点击收货,系统自动收货和用户自己点击了收货后发出提醒。
|
||||
try {
|
||||
$weapp_model = new Weapp($data[ 'site_id' ]);
|
||||
|
||||
// 检测微信小程序是否已开通发货信息管理服务
|
||||
$is_trade_managed = $weapp_model->orderShippingIsTradeManaged()['data'];
|
||||
if (!$is_trade_managed) return $weapp_model->success();
|
||||
|
||||
$filed = 'o.order_id,o.site_id,o.order_type,o.out_trade_no,o.pay_type,o.mobile,m.weapp_openid';
|
||||
$join = [
|
||||
[ 'member m', 'o.member_id=m.member_id', 'left' ]
|
||||
];
|
||||
$order_info = model('order')->getInfo([ [ 'order_id', '=', $data[ 'order_id' ] ] ], $filed, 'o', $join);
|
||||
if (empty($order_info)) {
|
||||
return $weapp_model->error('', '订单不存在');
|
||||
}
|
||||
if ($order_info[ 'pay_type' ] != 'wechatpay') {
|
||||
return $weapp_model->success('', '订单未使用微信支付');
|
||||
}
|
||||
if ($order_info[ 'order_type' ] != 1) {
|
||||
return $weapp_model->success('', '只有物流订单才能进行提醒');
|
||||
}
|
||||
|
||||
$param = [
|
||||
'site_id' => $order_info['site_id'],
|
||||
'out_trade_no' => $order_info['out_trade_no'],
|
||||
];
|
||||
$res = $weapp_model->orderShippingNotifyConfirmReceive($param);
|
||||
//dd($param,$res);
|
||||
return $res;
|
||||
}catch(\Exception $e){
|
||||
return error(-1, '小程序发送确认发货信息提醒错误,'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
29
addon/weapp/event/PhoneNumber.php
Executable file
29
addon/weapp/event/PhoneNumber.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\event;
|
||||
|
||||
use addon\weapp\model\Weapp;
|
||||
|
||||
/**
|
||||
* 开放数据解密
|
||||
*/
|
||||
class PhoneNumber
|
||||
{
|
||||
public function handle($param = [])
|
||||
{
|
||||
if ($param[ 'app_type' ] == 'weapp') {
|
||||
$res = ( new Weapp($param[ 'site_id' ]) )->decryptData($param);
|
||||
if ($res[ 'code' ] != 0) return $res;
|
||||
|
||||
return success(0, '', $res[ 'data' ][ 'purePhoneNumber' ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
addon/weapp/event/PointExchangeOrderPay.php
Executable file
27
addon/weapp/event/PointExchangeOrderPay.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\event;
|
||||
|
||||
use app\model\system\Cron;
|
||||
|
||||
/**
|
||||
* 礼品卡订单支付后
|
||||
*/
|
||||
class PointExchangeOrderPay
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
//类型 1商品 2优惠券 3红包 商品类型要在真实发货后才同步发货消息
|
||||
if($param['type'] != 1 && $param['exchange_price'] > 0){
|
||||
return (new Cron())->addCron(1, 0, "小程序虚拟发货", "WeappVirtualDelivery", time() + 60, $param['out_trade_no']);
|
||||
}
|
||||
}
|
||||
}
|
||||
41
addon/weapp/event/Qrcode.php
Executable file
41
addon/weapp/event/Qrcode.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\event;
|
||||
|
||||
use addon\weapp\model\Weapp;
|
||||
|
||||
/**
|
||||
* 二维码
|
||||
*/
|
||||
class Qrcode
|
||||
{
|
||||
/**
|
||||
* 二维码生成获取
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if ($param[ "app_type" ] == 'weapp' || $param[ "app_type" ] == 'all') {
|
||||
if ($param[ "app_type" ] == 'all') $param[ "app_type" ] = 'weapp';
|
||||
$weapp = new Weapp($param[ 'site_id' ]);
|
||||
if ($param[ "type" ] == 'create') {
|
||||
$res = $weapp->createQrcode($param);
|
||||
} else {
|
||||
$filename = $param[ 'qrcode_path' ] . '/' . $param[ 'qrcode_name' ] . '_' . $param[ 'app_type' ] . '.png';
|
||||
if (file_exists($filename)) {
|
||||
$res = success(0, '', [ 'type' => 'weapp', 'path' => $filename ]);
|
||||
} else {
|
||||
$res = $weapp->createQrcode($param);
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
25
addon/weapp/event/UnInstall.php
Executable file
25
addon/weapp/event/UnInstall.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return error("系统插件不能卸载");
|
||||
}
|
||||
}
|
||||
73
addon/weapp/event/WeappVirtualDelivery.php
Executable file
73
addon/weapp/event/WeappVirtualDelivery.php
Executable file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\event;
|
||||
|
||||
use addon\weapp\model\Weapp;
|
||||
use app\model\member\Member;
|
||||
use app\model\system\Pay as PayModel;
|
||||
|
||||
/**
|
||||
* 小程序虚拟发货
|
||||
* 支付后立即调用发货接口,微信会提示订单不存在,所以延迟一分钟执行,如果是
|
||||
* {"errcode":10060001,"errmsg":"支付单不存在 rid: 66235dcf-4803e8cf-5c30a69e"}
|
||||
*/
|
||||
class WeappVirtualDelivery
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
return $this->delivery($param['relate_id']);
|
||||
}
|
||||
|
||||
protected function delivery($out_trade_no)
|
||||
{
|
||||
//获取支付信息
|
||||
$pay_model = new PayModel();
|
||||
$pay_info = $pay_model->getPayInfo($out_trade_no)['data'];
|
||||
if(empty($pay_info)) return success();
|
||||
if ($pay_info[ 'pay_type' ] != 'wechatpay') return success();
|
||||
|
||||
// 检测微信小程序是否已开通发货信息管理服务
|
||||
$weapp_model = new Weapp($pay_info[ 'site_id' ]);
|
||||
$is_trade_managed = $weapp_model->orderShippingIsTradeManaged()['data'];
|
||||
if (!$is_trade_managed) return $weapp_model->success();
|
||||
|
||||
//用户信息
|
||||
$member_service = new Member();
|
||||
$member_info = $member_service->getMemberInfo([
|
||||
[ 'site_id', '=', $pay_info[ 'site_id' ] ],
|
||||
[ 'member_id', '=', $pay_info[ 'member_id' ] ]
|
||||
], 'weapp_openid')[ 'data' ];
|
||||
if(empty($member_info)) return success();
|
||||
|
||||
//组装发货信息
|
||||
$shipping_list = [
|
||||
[
|
||||
'tracking_no' => '', // 物流单号,物流快递发货时必填,示例值: 323244567777 字符字节限制: [1, 128]
|
||||
'express_company' => '', // 物流公司编码,快递公司ID,参见「查询物流公司编码列表」,物流快递发货时必填, 示例值: DHL 字符字节限制: [1, 128]
|
||||
'item_desc' => $weapp_model->handleOrderShippingItemDesc([$pay_info['pay_body']]), // 商品信息,例如:微信红包抱枕*1个,限120个字以内
|
||||
'contact' => [
|
||||
'consignor_contact' => '',
|
||||
'receiver_contact' => ''
|
||||
]
|
||||
]
|
||||
];
|
||||
$data = [
|
||||
'site_id' => $pay_info[ 'site_id' ],
|
||||
'out_trade_no' => $pay_info[ 'out_trade_no' ],
|
||||
'logistics_type' => Weapp::LOGISTICS_TYPE_VIRTUAL, // 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式
|
||||
'delivery_mode' => Weapp::UNIFIED_DELIVERY, // 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)
|
||||
'shipping_list' => $shipping_list,
|
||||
'weapp_openid' => $member_info[ 'weapp_openid' ], // 用户标识,用户在小程序appid下的唯一标识。 下单前需获取到用户的Openid 示例值: oUpF8uMuAJO_M2pxb1Q9zNjWeS6o 字符字节限制: [1, 128]
|
||||
'is_all_delivered' => true
|
||||
];
|
||||
return $weapp_model->orderShippingUploadShippingInfo($data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user