|
|
@@ -9,6 +9,7 @@ use app\model\saas\SaasChatMsg;
|
|
|
use app\model\saas\SaasChatStore;
|
|
|
use app\model\saas\SaasOrderPrice;
|
|
|
use app\service\saas\ChatStoreService;
|
|
|
+use app\service\saas\GoodsService;
|
|
|
use DI\Attribute\Inject;
|
|
|
use LinFly\Annotation\Attributes\Route\Controller;
|
|
|
use LinFly\Annotation\Attributes\Route\GetMapping;
|
|
|
@@ -29,6 +30,10 @@ class Service extends Base
|
|
|
#[Inject]
|
|
|
protected SaasChatStore $model;
|
|
|
|
|
|
+
|
|
|
+ #[Inject]
|
|
|
+ protected GoodsService $goodsService;
|
|
|
+
|
|
|
#[GetMapping('list')]
|
|
|
public function getServiceData(Request $request): Response
|
|
|
{
|
|
|
@@ -77,6 +82,34 @@ class Service extends Base
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ #[GetMapping('order')]
|
|
|
+ public function getMsgOrder(Request $request)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $param = $this->_valid([
|
|
|
+ "msgId.require" => trans("empty.require")
|
|
|
+ ]);
|
|
|
+ if (!is_array($param)) return error($param);
|
|
|
+ $productType = $this->goodsService->productType();
|
|
|
+ $chatStore = $this->model->where("id",$param['msgId'])->with(['orders' => function($query) use($productType){
|
|
|
+ $query->field("*")->with(['product' => function($query) use($productType){
|
|
|
+ $query->field("product_id,product_name,product_type")->append(['types'])->withAttr(['types' => function($query,$resp) use($productType){
|
|
|
+ $productTypeArr = [];
|
|
|
+ foreach ($productType as $val) {
|
|
|
+ $productTypeArr[$val['key']] = $val['name'];
|
|
|
+ }
|
|
|
+ return $productTypeArr[$resp['product_type']]??'';
|
|
|
+ }]);
|
|
|
+ }]);
|
|
|
+ }])->findOrEmpty();
|
|
|
+ if ($chatStore->isEmpty()) return error("error");
|
|
|
+ return success("ok",['order' => $chatStore['orders']]);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return error($th->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
#[PostMapping('send')]
|
|
|
public function sendMessageData(Request $request): Response
|
|
|
{
|