|
@@ -0,0 +1,84 @@
|
|
|
+<?php
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | Author: 萤火科技 <admin@yiovo.com>
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+declare (strict_types = 1);
|
|
|
+
|
|
|
+namespace app\console\service;
|
|
|
+
|
|
|
+use app\console\library\Tools;
|
|
|
+use app\common\service\BaseService;
|
|
|
+use app\console\model\User;
|
|
|
+use app\console\model\User as UserModel;
|
|
|
+use app\console\model\user\BonusHistory;
|
|
|
+use app\console\model\user\CommissionsDetail;
|
|
|
+use app\store\model\Express as ExpressModel;
|
|
|
+use app\store\model\Order;
|
|
|
+use app\store\model\OrderAddress;
|
|
|
+use app\store\model\OrderGoods;
|
|
|
+use app\store\service\wxApi\WxOrderLogistics;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 服务类:每日计算店内职员的当月的业绩
|
|
|
+ * Class UserGrade
|
|
|
+ * @package app\console\service
|
|
|
+ */
|
|
|
+class WxDelivery extends BaseService
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * 每日计算店内职员的当月的业绩v.1.3.6
|
|
|
+ * @param int $storeId
|
|
|
+ * @return array|bool
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function pullOrderStatus(int $storeId)
|
|
|
+ {
|
|
|
+ // 获取店内员工的预计佣金
|
|
|
+ $data = [];
|
|
|
+ $orderGoodsModel = new OrderGoods();
|
|
|
+ $orderGoodses = $orderGoodsModel->getNeedToWxDelivery();
|
|
|
+ $orderIds = array_column($orderGoodses,'order_id');
|
|
|
+ $orderModel = new Order();
|
|
|
+ $orders = $orderModel->getListByIds($orderIds);
|
|
|
+
|
|
|
+ $express = ExpressModel::getAllList();
|
|
|
+ $expressIndexById = array_column($express,null,'express_id');
|
|
|
+
|
|
|
+ $orderAddressModel = new OrderAddress();
|
|
|
+ $orderAddress = $orderAddressModel->batchByOrderIds($orderIds);
|
|
|
+ $orderAddressIndexByOrderId = array_column($orderAddress,'phone','order_id');
|
|
|
+
|
|
|
+ $userIds = array_column($orderGoodses,'user_id');
|
|
|
+ $users = \app\store\model\User::getByUserIds($userIds);
|
|
|
+ $userToOpenId = array_column($users,'open_id','user_id');
|
|
|
+
|
|
|
+ // 遍历整理数据
|
|
|
+ foreach ($orderGoodses as $orderGoods) {
|
|
|
+ $res = WxOrderLogistics::getOrderStatusByTransId($orders[$orderGoods['order_id']]['transaction_id']);
|
|
|
+ if ($res['code'] == 10060020){
|
|
|
+ $a = WxOrderLogistics::orderDeliveryByTransId($orders[$orderGoods['order_id']]['transaction_id'],
|
|
|
+ $expressIndexById[$orderGoods['express_id']]['wx_delivery_id'],$orderGoods['express_no'],$orderGoods['goods_name'],$userToOpenId[$orderGoods['user_id']],'',$orderAddressIndexByOrderId[$orderGoods['order_id']]);
|
|
|
+ if ($a['code'] == 'ok'){
|
|
|
+ OrderGoods::update(['wx_delivery_status'=>20],['order_goods_id'=>$orderGoods['order_goods_id']]);
|
|
|
+ }
|
|
|
+ dd($a);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 记录日志
|
|
|
+ Tools::taskLogs('WxDelivery', 'pullOrderStatus', [
|
|
|
+ 'storeId' => $storeId,
|
|
|
+ 'data' => $data
|
|
|
+ ]);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|