|
|
@@ -7,17 +7,24 @@ use app\extra\dyLife\data\OrderData;
|
|
|
use app\extra\dyLife\Token;
|
|
|
use app\extra\dyMini\Relation;
|
|
|
use app\extra\tools\CodeExtend;
|
|
|
+use app\extra\tools\LifeWeb;
|
|
|
use app\middleware\AuthMiddleware;
|
|
|
use app\model\saas\SaasGoods;
|
|
|
use app\model\saas\SaasGoodsSku;
|
|
|
+use app\model\saas\SaasLivePlanGoods;
|
|
|
+use app\model\saas\SaasLivePlanStar;
|
|
|
use app\model\saas\SaasOrder;
|
|
|
use app\model\saas\SaasOrderItem;
|
|
|
use app\model\saas\SaasOrderVerify;
|
|
|
+use app\model\saas\SaasStar;
|
|
|
use LinFly\Annotation\Attributes\Route\Controller;
|
|
|
use LinFly\Annotation\Attributes\Route\GetMapping;
|
|
|
use LinFly\Annotation\Attributes\Route\RequestMapping;
|
|
|
use support\Request;
|
|
|
use support\Response;
|
|
|
+use Webman\RedisQueue\Redis;
|
|
|
+use Workerman\Timer;
|
|
|
+use yzh52521\EasyHttp\Http;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -163,35 +170,83 @@ class Solution extends Base
|
|
|
}
|
|
|
|
|
|
#[GetMapping("test")]
|
|
|
- public function setTest()
|
|
|
+ public function setTest(Request $request): Response
|
|
|
{
|
|
|
try {
|
|
|
+ $param = $this->_valid([
|
|
|
+ "order.require" => trans("empty.require")
|
|
|
+ ],$request->method());
|
|
|
+ if (!is_array($param)) return error($param);
|
|
|
+ Redis::send("sync-order-info",['order' => $param['order']],30);
|
|
|
+ return success("ok");
|
|
|
+// $order = (new SaasOrder)->where("order_sn",$param['order'])->findOrEmpty();
|
|
|
+// if ($order->isEmpty()) return error("数据不存在");
|
|
|
+// [$state,$resp] = (new LifeWeb)->token()->getOrderData($param['order']);
|
|
|
+// if (!$state) return error($resp);
|
|
|
+// $order->douyin_uid = $resp['douyin_uid'];
|
|
|
+// $order->life_fee = $resp['life_fee'];
|
|
|
+// $order->star_fee = $resp['star_fee'];
|
|
|
+// $order->save();
|
|
|
+// return successTrans("success.data",$resp);
|
|
|
// $data = (new Relation)->config($this->getDyConfig())->token()->createOrderFirst(['1865253598118939']);
|
|
|
- $data = (new SaasOrder)->where('status',2)->whereNull("douyin_uid")->select();
|
|
|
// $data = (new SaasOrderVerify)->where("status",0)->with(['orders'])->select();
|
|
|
- if ($data->isEmpty()) return error("err");
|
|
|
- $upData = [];
|
|
|
- foreach ($data as $key=>$item) {
|
|
|
- // 查询订单详情
|
|
|
- $orderData = (new OrderData)->config([
|
|
|
- "appid" => sConf("wechat.appid"),
|
|
|
- "secret" => sConf("wechat.secret"),
|
|
|
- "account" => sConf("wechat.shop_id"),
|
|
|
- ])->token()->getOrderData($item['order_sn']);
|
|
|
- if (isset($orderData['orders'][0]['anchor_id'])) {
|
|
|
- $upData[$key] = [
|
|
|
- "douyin_uid" => $orderData['orders'][0]['anchor_id'],
|
|
|
- "id" => $item['id']
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- if (!empty($upData)) {
|
|
|
- (new SaasOrder)->saveAll(array_values($upData));
|
|
|
- }
|
|
|
- return success("ok",array_values($upData));
|
|
|
+// $data = (new SaasOrder)->where('status',2)->whereNull("douyin_uid")->select();
|
|
|
+// $data = (new SaasOrder)->where('status','in',[1,2,3,6])->select();
|
|
|
+// if ($data->isEmpty()) return error("err");
|
|
|
+// $upData = [];
|
|
|
+// foreach ($data as $key=>$item) {
|
|
|
+// // 查询订单详情
|
|
|
+// [$state,$resp] = (new LifeWeb)->token()->getOrderData($item['order_sn']);
|
|
|
+// if (!$state) {
|
|
|
+// echo getDateFull()."==={$item['order_sn']}===订单获取失败\n";
|
|
|
+// } else {
|
|
|
+// echo getDateFull()."==={$item['order_sn']}===执行更新\n";
|
|
|
+// print_r($resp);
|
|
|
+// $upData[$key] = [
|
|
|
+// "douyin_uid" => $resp['douyin_uid'],
|
|
|
+// "star_fee" => $resp['star_fee'],
|
|
|
+// "life_fee" => $resp['life_fee'],
|
|
|
+// "id" => $item['id']
|
|
|
+// ];
|
|
|
+// }
|
|
|
+// Timer::sleep(1.5);
|
|
|
+// }
|
|
|
+// if (!empty($upData)) {
|
|
|
+// (new SaasOrder)->saveAll(array_values($upData));
|
|
|
+// }
|
|
|
+// return success("ok",$upData);
|
|
|
+// $param = $this->_valid([
|
|
|
+// "order.require" => trans("empty.require")
|
|
|
+// ],$request->method());
|
|
|
+// if (!is_array($param)) return error($param);
|
|
|
+// $order = (new SaasOrder)->where("order_sn",$param['order'])->findOrEmpty();
|
|
|
+// if ($order->isEmpty()) return errorTrans("empty.data");
|
|
|
+// $douyin = (new SaasStar)->where("uid",$order['douyin_uid'])->value("unique_id");
|
|
|
+// $productRate = $this->getDyUidProduct($douyin,$order['life_goods_id']);
|
|
|
+// return success("ok",$productRate);
|
|
|
} catch (\Throwable $throwable) {
|
|
|
+ echo $throwable->getMessage()."\n";
|
|
|
+ echo $throwable->getFile()."\n";
|
|
|
+ echo $throwable->getLine()."\n";
|
|
|
return error($throwable->getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ protected function getDyUidProduct(string $dyUid = "",string $goodsId = ""): array
|
|
|
+ {
|
|
|
+ $starPlan = (new SaasLivePlanStar)->where("unique_id",$dyUid)->column("plan_id");
|
|
|
+ if (empty($starPlan)) return [];
|
|
|
+ print_r($starPlan);
|
|
|
+ $productIds = (new SaasLivePlanGoods)->where("plan_id","in",$starPlan)->column("goods_id,commission_rate,plan_id");
|
|
|
+ if (empty($productIds)) return [];
|
|
|
+ $goodsReturn = [];
|
|
|
+ foreach ($productIds as $key=>$productId) {
|
|
|
+ if ($productId['goods_id'] == $goodsId) {
|
|
|
+ $goodsReturn[$key] = $productId;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $goodsReturn;
|
|
|
+ }
|
|
|
+
|
|
|
}
|