|
|
@@ -5,7 +5,10 @@ namespace app\controller\api;
|
|
|
use app\extra\basic\Base;
|
|
|
use app\extra\dyLife\Token;
|
|
|
use app\extra\dyMini\Relation;
|
|
|
+use app\extra\tools\CodeExtend;
|
|
|
use app\middleware\AuthMiddleware;
|
|
|
+use app\model\saas\SaasGoods;
|
|
|
+use app\model\saas\SaasOrder;
|
|
|
use LinFly\Annotation\Attributes\Route\Controller;
|
|
|
use LinFly\Annotation\Attributes\Route\GetMapping;
|
|
|
use LinFly\Annotation\Attributes\Route\RequestMapping;
|
|
|
@@ -29,7 +32,60 @@ class Solution extends Base
|
|
|
$data = $request->all();
|
|
|
echo getDateFull()."===扩展回调\n";
|
|
|
print_r($data);
|
|
|
- print_r($request->rawBody());
|
|
|
+ if (isset($data['operate_type'])) {
|
|
|
+ if ($data['status'] == "PASS") { // 创建商品回调
|
|
|
+ $goods = (new SaasGoods)->where("goods_id",$data['product_id'])->findOrEmpty();
|
|
|
+ if ($goods->isEmpty()) return json(['err_no' => 0,"err_tips" => "success"]);
|
|
|
+ $goods->status = 1;
|
|
|
+ $goods->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($data['type']))
|
|
|
+ {
|
|
|
+ $msgData = json_decode($data['msg'],true);
|
|
|
+ switch ($data['type'])
|
|
|
+ {
|
|
|
+ case "pre_create_order": // 预下单
|
|
|
+ if (!isset($msgData['item_order_info_list'][0]['goods_id'])) return json(['err_no' => 0,"err_tips" => "success"]);
|
|
|
+ $goods = (new SaasGoods)->where("goods_id",$msgData['item_order_info_list'][0]['goods_id'])->findOrEmpty();
|
|
|
+ if ($goods->isEmpty()) return json(['err_no' => 0,"err_tips" => "success"]);
|
|
|
+ $order = (new SaasOrder)->where("order_sn",$msgData['order_id'])->findOrEmpty();
|
|
|
+ if (!$order->isEmpty()) return json(['err_no' => 0,"err_tips" => "success"]);
|
|
|
+ $orderSn = "AL".CodeExtend::uniqidDate(18).rand(100,999);
|
|
|
+ $goodsImg = is_string($goods['image_list'])?json_decode($goods['image_list'],true):[];
|
|
|
+ $order->insertGetId([
|
|
|
+ "out_order_no" => $orderSn,
|
|
|
+ "order_sn" => $msgData['order_id'],
|
|
|
+ "openid" => $msgData['open_id'],
|
|
|
+ "goods_id" => $goods['id'],
|
|
|
+ "life_goods_id" => $goods['goods_id'],
|
|
|
+ "product_id" => $goods['product_id'],
|
|
|
+ "sku_id" => "",
|
|
|
+ "number" => $msgData['goods'][0]['quantity']??1,
|
|
|
+ "price" => $msgData['item_order_info_list'][0]['price']?:$goods['price'],
|
|
|
+ "line_price" => $goods['line_price']*100,
|
|
|
+ "poi_id" => $goods['poi_id'],
|
|
|
+ "img" => $goodsImg[0]['url'],
|
|
|
+ "sku_name" => "",
|
|
|
+ "mobile" => $msgData['phone_num']??'',
|
|
|
+ "pay_money" => $msgData['total_amount']??0,
|
|
|
+ ]);
|
|
|
+ return json(['err_no' => 0,"err_tips" => "success","data" => [
|
|
|
+ "order_entry_schema" => [
|
|
|
+ "path" => "page/order/detail",
|
|
|
+ "params" => json_encode([
|
|
|
+ "order" => $orderSn
|
|
|
+ ])
|
|
|
+ ],
|
|
|
+ "out_order_no" => $orderSn,
|
|
|
+ "pay_expire_seconds" => 300,
|
|
|
+ "pay_notify_url" => "https://tran.jsshuita.cn/notify/douyin"
|
|
|
+ ]]);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
return json(['err_no' => 0,"err_tips" => "success"]);
|
|
|
} catch (\Throwable $throwable) {
|
|
|
return error($throwable->getMessage());
|