|
@@ -3,9 +3,11 @@
|
|
|
namespace app\controller\service;
|
|
namespace app\controller\service;
|
|
|
|
|
|
|
|
use app\extra\basic\Base;
|
|
use app\extra\basic\Base;
|
|
|
|
|
+use app\extra\tools\CodeExtend;
|
|
|
use app\middleware\AuthMiddleware;
|
|
use app\middleware\AuthMiddleware;
|
|
|
use app\model\saas\SaasChatMsg;
|
|
use app\model\saas\SaasChatMsg;
|
|
|
use app\model\saas\SaasChatStore;
|
|
use app\model\saas\SaasChatStore;
|
|
|
|
|
+use app\model\saas\SaasOrderPrice;
|
|
|
use app\service\saas\ChatStoreService;
|
|
use app\service\saas\ChatStoreService;
|
|
|
use DI\Attribute\Inject;
|
|
use DI\Attribute\Inject;
|
|
|
use LinFly\Annotation\Attributes\Route\Controller;
|
|
use LinFly\Annotation\Attributes\Route\Controller;
|
|
@@ -112,4 +114,67 @@ class Service extends Base
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ #[PostMapping('send/price')]
|
|
|
|
|
+ public function sendPriceData(Request $request)
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $param = $this->_valid([
|
|
|
|
|
+ "name.require" => trans("empty.require"),
|
|
|
|
|
+ "price.require" => trans("empty.require"),
|
|
|
|
|
+ "groupId.require" => trans("empty.require"),
|
|
|
|
|
+ "openid.require" => trans("empty.require"),
|
|
|
|
|
+ "type.require" => trans("empty.require"),
|
|
|
|
|
+ ],"post");
|
|
|
|
|
+ if (!is_array($param)) return error($param);
|
|
|
|
|
+ $orderSn = CodeExtend::uniqidDate(18,"P");
|
|
|
|
|
+ $msgId = time();
|
|
|
|
|
+ $priceState = (new SaasOrderPrice)->insertGetId([
|
|
|
|
|
+ "openid" => $param['openid'],
|
|
|
|
|
+ "poi_id" => $param['groupId'],
|
|
|
|
|
+ "service_id" => $request->user['id'],
|
|
|
|
|
+ "name" => $param['name'],
|
|
|
|
|
+ "price" => $param['price'] * 100,
|
|
|
|
|
+ "image" => "https://jymini.oss-cn-guangzhou.aliyuncs.com/mini/chajia.jpg",
|
|
|
|
|
+ "order_sn" => $orderSn,
|
|
|
|
|
+ "msgId" => $msgId,
|
|
|
|
|
+ ]);
|
|
|
|
|
+ if (!$priceState) return errorTrans("error.data");
|
|
|
|
|
+ $msgData = [
|
|
|
|
|
+ "img" => "https://jymini.oss-cn-guangzhou.aliyuncs.com/mini/chajia.jpg",
|
|
|
|
|
+ "name" => $param['name'],
|
|
|
|
|
+ "order" => $orderSn,
|
|
|
|
|
+ "price" => $param['price'],
|
|
|
|
|
+ "msgId" => $msgId,
|
|
|
|
|
+ "status" => 0
|
|
|
|
|
+ ];
|
|
|
|
|
+ $state = (new SaasChatMsg)->insertGetId([
|
|
|
|
|
+ "source" => 2,
|
|
|
|
|
+ "openid" => $param['openid'],
|
|
|
|
|
+ "content" => json_encode($msgData),
|
|
|
|
|
+ "type" => $param['type'],
|
|
|
|
|
+ "msgId" => $msgId,
|
|
|
|
|
+ "poi_id" => $param['groupId'],
|
|
|
|
|
+ "service_id" => $request->user['id'],
|
|
|
|
|
+ ]);
|
|
|
|
|
+ if (!$state) return errorTrans("error.data");
|
|
|
|
|
+ $api = new Api('http://127.0.0.1:3232', config('plugin.webman.push.app.app_key'),config('plugin.webman.push.app.app_secret'));
|
|
|
|
|
+ $api->trigger("user-{$param['openid']}","message",[
|
|
|
|
|
+ "type" => $param['type'],
|
|
|
|
|
+ "time" => time() * 1000,
|
|
|
|
|
+ "msgId" => time(),
|
|
|
|
|
+ "content" => json_encode($msgData),
|
|
|
|
|
+ "source" => 2,
|
|
|
|
|
+ "avatar" => "https://washmy.oss-cn-guangzhou.aliyuncs.com/storage/20260511/23627b2cb8f73a8a90b95c31d726e6ecad0cbb9a.png",
|
|
|
|
|
+ "poi_id" => $param['groupId'],
|
|
|
|
|
+ "openid" => $param['openid'],
|
|
|
|
|
+ "service_id" => $request->user['id'],
|
|
|
|
|
+ "create_at" => formatTime(time()),
|
|
|
|
|
+ ]);
|
|
|
|
|
+ return successTrans("success.data",$msgData);
|
|
|
|
|
+ } catch (\Throwable $throwable) {
|
|
|
|
|
+ return error($throwable->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|