作者 刘朕
1 个管道 的构建 通过 耗费 1 秒

合并分支 'liuzhen' 到 'master'

Liuzhen



查看合并请求 !107
... ... @@ -8,13 +8,20 @@ use addons\litestore\model\Litestoreorder;
use addons\litestore\model\Wxlitestoregoods;
use addons\third\model\Third;
use app\admin\model\Litestorenews;
use app\api\model\GoodsMsg;
use app\api\model\LitestoreBanner;
use app\api\model\LitestoreGoodsSpec;
use app\api\model\Message;
use app\api\model\StoreComment;
use app\api\model\UserSearch;
use app\api\validate\GoodsValidate;
use app\api\validate\StoreValidate;
use app\common\controller\Api;
use EasyWeChat\Foundation\Application as WXPAY_APP;
use EasyWeChat\Payment\Order as WXPAY_ORDER;
use think\Db;
use think\Exception;
use think\exception\PDOException;
use think\Request;
/**
... ... @@ -405,6 +412,61 @@ class Goods extends Api
}
/**
* 客服留言提交
* @ApiWeigh (35)
*
* @ApiTitle (客服留言提交)
* @ApiSummary (客服留言提交)
* @ApiMethod (POST)
* @ApiRoute (/api/goods/msg)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="goods_id", type="integer", required=true, description="商品id")
* @ApiParams (name="content", type="string", required=true, description="内容")
* @ApiParams (name="mobile", type="string", required=true, description="联系方式")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": {
}
})
*/
public function msg()
{
$param = (new StoreValidate())->goCheck('msg');
$where = [
'where' => [
'id' => $param['goods_id']
]
];
$goods = $this->goods_model->findOrFail($where);
$msg_model = new GoodsMsg();
Db::startTrans();
$result = false;
try{
$add = [
'user_id' => $this->auth->id,
'store_id' => $goods['object_id'],
'content' => $param['content'],
'mobile' => $param['mobile'],
];
$result = $msg_model->add($add);
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if(!$result) {
$this->error('留言失败');
}
$this->success('留言成功');
}
/**
* 立即购买
* @ApiWeigh (25)
*
... ...
<?php
namespace app\api\model;
class GoodsMsg extends Base
{
}
\ No newline at end of file
... ...
... ... @@ -23,7 +23,8 @@ class StoreValidate extends BaseValidate
'msg_id' => 'require',
'number' => 'require',
'deposit_id' => 'require',
'inform_id' => 'require'
'inform_id' => 'require',
'goods_id' => 'require'
];
protected $message = [
'page.integer' =>'页数必须是整数',
... ... @@ -45,5 +46,6 @@ class StoreValidate extends BaseValidate
'comment_detail_pt' => ['msg_id'], // 留言详情-平台
'comment_reply' => ['msg_id'], // 留言回复
'deposit_order' => ['deposit_id'], // 板币充值提交
'msg' => ['goods_id','content','mobile'], // 客服留言提交
];
}
\ No newline at end of file
... ...