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

合并分支 'liuzhen' 到 'master'

店铺申请接口调试



查看合并请求 !3
<?php
namespace app\api\controller;
use addons\litestore\model\Litestoreorder;
use app\api\model\LitestoreBanner;
use app\api\model\LitestoreGoodsSpec;
use app\api\model\UserSearch;
use app\common\controller\Api;
use EasyWeChat\Foundation\Application;
use EasyWeChat\Payment\Order;
use think\Db;
use think\Exception;
use think\exception\PDOException;
use think\Request;
/**
* 店铺接口
*/
class Store extends Api
{
protected $noNeedLogin = [];
protected $noNeedRight = ['*'];
protected $store_model;
protected $goods_model;
protected $banner_model;
protected $spec_model;
protected $search_model;
protected $favorite_model;
protected $comment_model;
protected $good_model;
protected $follow_model;
protected $user_id;
public function __construct(Request $request, LitestoreBanner $banner, \app\api\model\LitestoreGoods $goods,LitestoreGoodsSpec $spec,UserSearch $search,\app\api\model\Store $store)
{
parent::__construct($request);
$this->banner_model = $banner;
$this->goods_model = $goods;
$this->spec_model = $spec;
$this->search_model = $search;
$this->store_model = $store;
$this->user_id = $this->auth->id;
}
/**
* 店铺申请
* @ApiWeigh (3)
*
* @ApiTitle (店铺申请)
* @ApiSummary (店铺申请)
* @ApiMethod (POST)
* @ApiRoute (/api/store/store_add)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="store_name", type="integer", required=true, description="店铺名称")
* @ApiParams (name="house_ids", type="string", sample="店铺1id,店铺2id", required=true, description="入驻社区")
* @ApiParams (name="job", type="string", sample="[{'name':'职位名称1','number':'招聘人数1'},{'name':'职位名称2','number':'招聘人数2'}]", required=true, description="招聘职位")
* @ApiParams (name="industry_id", type="string", required=true, description="行业/关键词id")
* @ApiParams (name="name", type="string", required=true, description="联系人姓名")
* @ApiParams (name="mobile", type="string", required=true, description="联系人手机号")
* @ApiParams (name="license", 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':'返回成功'
})
*/
public function store_add()
{
// $param = (new RecruitValidate())->goCheck('add');
$order_sn = $param['order_sn'] = get_order_sn();
$pay_data = [];
if($this->auth->end_time > time()) {
$param['status'] = 2;
} else {
$param['status'] = 1;
// 获取小程序配置
$options = \config('miniprogram.basic');
$app = new Application($options);
$payment = $app->payment;
// 获取支付参数
$attributes = [
'body' => '发布招募合伙人',
'out_trade_no' => $order_sn,
'total_fee' => 1, // $param['money'] * 100
'spbill_create_ip' => request()->ip(), // 可选,如不传该参数,SDK 将会自动获取相应 IP 地址
'notify_url' => url('index/ajax/notify',[],true,true), // 支付结果通知网址,如果不设置则会使用配置里的默认地址
'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
'openid' => Db::name('third')->where('user_id',$this->auth->id)->value('openid'),
];
$order = new Order($attributes);
$order_result = $payment->pay($order);
if($order_result['return_code'] == 'SUCCESS' && $order_result['result_code'] == 'SUCCESS') {
$prepayId = $order_result->prepay_id;
} else {
$this->error($order_result['return_msg']);
}
}
Db::startTrans();
$result = false;
$result_invite = true;
try{
$param['user_id'] = $this->auth->id;
$result = $this->store_model->add($param);
$id = $this->store_model->id;
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if(!$result || !$result_invite) {
$this->error('申请提交失败');
}
$this->success('申请提交成功',['id'=>$id,'status'=>$param['status'],'pay_data'=>$pay_data]);
}
}
\ No newline at end of file
... ...
<?php
namespace app\api\model;
class Store extends Base
{
}
\ No newline at end of file
... ...
... ... @@ -362,3 +362,13 @@ if (!function_exists('hsv2rgb')) {
];
}
}
if(!function_exists('get_order_sn')) {
function get_order_sn()
{
// 获取毫秒
$micro = explode('.',explode(' ',microtime())[0])[1];
return date('YmdHis').substr($micro,0,5).rand(0,9);
}
}
\ No newline at end of file
... ...
... ... @@ -36,4 +36,5 @@ return array (
'mail_verify_type' => '2',
'mail_from' => '10000@qq.com',
'contact' => '联系我们联系我们022-12345678',
'settled' => '上架入驻协议',
);
\ No newline at end of file
... ...
此 diff 太大无法显示。