作者 Cool
1 个管道 的构建 失败 耗费 1 秒

后台充值管理开发,充值接口调试

正在显示 31 个修改的文件 包含 1029 行增加39 行删除
<?php
namespace app\admin\controller\deposit;
use app\common\controller\Backend;
/**
* 板币充值配置管理
*
* @icon fa fa-circle-o
*/
class Deposit extends Backend
{
/**
* Deposit模型对象
* @var \app\admin\model\deposit\Deposit
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\deposit\Deposit;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}
... ...
<?php
namespace app\admin\controller\deposit;
use app\common\controller\Backend;
/**
* 充值订单管理
*
* @icon fa fa-circle-o
*/
class DepositOrder extends Backend
{
/**
* DepositOrder模型对象
* @var \app\admin\model\deposit\DepositOrder
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\deposit\DepositOrder;
$this->view->assign("statusList", $this->model->getStatusList());
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax())
{
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField'))
{
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->with(['user'])
->where($where)
->order($sort, $order)
->count();
$list = $this->model
->with(['user'])
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->select();
foreach ($list as $row) {
$row->getRelation('user')->visible(['nickname']);
}
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
return json($result);
}
return $this->view->fetch();
}
}
... ...
... ... @@ -104,7 +104,7 @@ class Store extends Backend
$params = $this->preExcludeFields($params);
$admin_model = new Admin();
$auth_group_model = new AuthGroupAccess();
if($params['status'] == 2) {
if($params['status'] == 3) {
$salt = Random::alnum();
$password = md5(md5($params['password']) . $salt);
$admin_data = [
... ... @@ -123,13 +123,13 @@ class Store extends Backend
try {
$result = $row->allowField(true)->save($params);
// 判断审核状态
if($params['status'] == 2) {
if($params['status'] == 3) {
// 审核通过,新增商家管理员
$result_admin = $admin_model->isUpdate(false)->save($admin_data);
$auth_group_data['uid'] = $admin_model->id;
$result_auth_group = $auth_group_model->isUpdate(false)->save($auth_group_data);
}
if($params['status'] == 3) {
if($params['status'] == 4) {
// 审核不通过,执行退款操作
$refund = [
'order_id' => $row->id,
... ...
<?php
return [
'Money' => '充值金额',
'Score' => '板币数量',
'Weigh' => '排序',
'Createtime' => '生成时间',
'Updatetime' => '更新时间'
];
... ...
<?php
return [
'Order_sn' => '订单号',
'User_id' => '用户id',
'Deposit_id' => '充值id',
'Score' => '板币数量',
'Money' => '支付金额',
'Status' => '状态',
'Status 1' => '待付款',
'Status 2' => '已支付',
'Pay_time' => '支付时间',
'Transaction_id' => '微信支付ID',
'Createtime' => '生成时间',
'Updatetime' => '更新时间',
'User.nickname' => '昵称'
];
... ...
... ... @@ -11,9 +11,10 @@ return [
'Mobile' => '联系人手机号',
'License' => '营业执照',
'Status' => '状态',
'Status 1' => '待审核',
'Status 2' => '审核通过',
'Status 3' => '审核驳回',
'Status 1' => '待支付',
'Status 2' => '待审核',
'Status 3' => '审核通过',
'Status 4' => '审核驳回',
'Pay_time' => '支付时间',
'Transaction_id' => '微信支付ID',
'Store_icon' => '店铺图标',
... ...
<?php
namespace app\admin\model\deposit;
use think\Model;
class Deposit extends Model
{
// 表名
protected $name = 'deposit';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
];
protected static function init()
{
self::afterInsert(function ($row) {
$pk = $row->getPk();
$row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
});
}
}
... ...
<?php
namespace app\admin\model\deposit;
use think\Model;
class DepositOrder extends Model
{
// 表名
protected $name = 'deposit_order';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
'status_text',
'pay_time_text'
];
public function getStatusList()
{
return ['1' => __('Status 1'), '2' => __('Status 2')];
}
public function getStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
$list = $this->getStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getPayTimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['pay_time']) ? $data['pay_time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
protected function setPayTimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
public function user()
{
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
... ...
<?php
namespace app\admin\validate\deposit;
use think\Validate;
class Deposit extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<?php
namespace app\admin\validate\deposit;
use think\Validate;
class DepositOrder extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-money" data-rule="required" class="form-control" step="0.01" name="row[money]" type="number" value="0.00">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-score" data-rule="required" class="form-control" name="row[score]" type="number" value="0">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="0">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-money" data-rule="required" class="form-control" step="0.01" name="row[money]" type="number" value="{$row.money|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-score" data-rule="required" class="form-control" name="row[score]" type="number" value="{$row.score|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('deposit/deposit/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('deposit/deposit/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('deposit/deposit/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<!-- <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('deposit/deposit/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->
<!-- <div class="dropdown btn-group {:$auth->check('deposit/deposit/multi')?'':'hide'}">-->
<!-- <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!-- <ul class="dropdown-menu text-left" role="menu">-->
<!-- <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>-->
<!-- <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>-->
<!-- </ul>-->
<!-- </div>-->
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('deposit/deposit/edit')}"
data-operate-del="{:$auth->check('deposit/deposit/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Order_sn')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-order_sn" data-rule="required" class="form-control" name="row[order_sn]" type="text" value="''">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Deposit_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-deposit_id" data-rule="required" data-source="deposit/index" class="form-control selectpage" name="row[deposit_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-score" data-rule="required" class="form-control" name="row[score]" type="number" value="0">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-money" data-rule="required" class="form-control" step="0.01" name="row[money]" type="number" value="0.00">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="statusList" item="vo"}
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="1"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Pay_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-pay_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[pay_time]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Transaction_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-transaction_id" data-rule="required" data-source="transaction/index" class="form-control selectpage" name="row[transaction_id]" type="text" value="">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Order_sn')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-order_sn" data-rule="required" class="form-control" name="row[order_sn]" type="text" value="{$row.order_sn|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Deposit_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-deposit_id" data-rule="required" data-source="deposit/index" class="form-control selectpage" name="row[deposit_id]" type="text" value="{$row.deposit_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-score" data-rule="required" class="form-control" name="row[score]" type="number" value="{$row.score|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-money" data-rule="required" class="form-control" step="0.01" name="row[money]" type="number" value="{$row.money|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="statusList" item="vo"}
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Pay_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-pay_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[pay_time]" type="text" value="{:$row.pay_time?datetime($row.pay_time):''}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Transaction_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-transaction_id" data-rule="required" data-source="transaction/index" class="form-control selectpage" name="row[transaction_id]" type="text" value="{$row.transaction_id|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
<div class="panel-heading">
{:build_heading(null,FALSE)}
<ul class="nav nav-tabs" data-field="status">
<li class="active"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
{foreach name="statusList" item="vo"}
<li><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
{/foreach}
</ul>
</div>
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('deposit/deposit_order/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('deposit/deposit_order/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('deposit/deposit_order/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('deposit/deposit_order/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
<div class="dropdown btn-group {:$auth->check('deposit/deposit_order/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul>
</div>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('deposit/deposit_order/edit')}"
data-operate-del="{:$auth->check('deposit/deposit_order/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
<?php
namespace app\api\behavior\user;
class User{
public function userInit(&$params){
$user_model = (new \app\api\model\User());
$user_model->dataUpdate(['username'=>$params['username']]);
}
}
... ...
... ... @@ -53,6 +53,34 @@ class Store extends Api
}
/**
* 入驻协议
* @ApiWeigh (90)
*
* @ApiTitle (入驻协议)
* @ApiSummary (入驻协议)
* @ApiMethod (POST)
* @ApiRoute (/api/store/settled)
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": {
"settled": 入驻协议,
}
})
*/
public function settled()
{
if($this->request->isPost()){
$return = [
'settled' => config('site.settled')
];
$this->success('成功',$return);
}
}
/**
* 行业列表
* @ApiWeigh (80)
*
... ... @@ -121,6 +149,22 @@ class Store extends Api
public function store_add()
{
$param = (new StoreValidate())->goCheck('store_add');
$where_s = ['user_id'=>$this->user_id];
$where = [
'where' => $where_s
];
$store = $this->store_model->findOrFail($where,false,'*','createtime');
if($store) {
if($store['status'] == 1) {
$param['id'] = $store['id'];
}
if($store['status'] == 2) {
$this->error('商家申请仍在审核中');
}
if($store['status'] == 3) {
$this->error('商家申请已通过');
}
}
$order_sn = $param['order_sn'] = get_order_sn();
$pay_data = [];
// if($this->auth->end_time > time()) {
... ... @@ -155,7 +199,11 @@ class Store extends Api
$result_invite = true;
try{
$param['user_id'] = $this->auth->id;
$result = $this->store_model->add($param);
if(!empty($param['id'])) {
$result = $this->store_model->edit($param);
} else {
$result = $this->store_model->add($param);
}
$id = $this->store_model->id;
Db::commit();
} catch (PDOException $e) {
... ... @@ -270,7 +318,15 @@ class Store extends Api
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
'msg':'返回成功',
"data": {
"id": 1,
"store_name": "123",
"image_arr": [
"http://cloud.caiyunpan.brotop.cn/assets/img/qrcode.png",
"http://cloud.caiyunpan.brotop.cn/assets/img/qrcode.png"
]
}
})
*/
public function store()
... ... @@ -458,7 +514,7 @@ class Store extends Api
/**
* 留言消息
* @ApiWeigh (80)
* @ApiWeigh (24)
*
* @ApiTitle (留言消息)
* @ApiSummary (留言消息)
... ... @@ -472,27 +528,27 @@ class Store extends Api
'code':'1',
'msg':'返回成功',
"data": {
"list": [
{
"id": 1,
"name": "行业名称",
"weigh": 0,
}
]
"list": [
{
"id": 1,
"name": "行业名称",
"weigh": 0,
}
]
}
})
*/
public function store_list()
public function comment_list()
{
if($this->request->isPost()){
$param = (new StoreValidate())->goCheck('comment_reply');
$param = (new StoreValidate())->goCheck('common');
$store = $this->get_store();
$page = $param['page'];
$where = [
'where' => ['store_id'=>$store['id']],
'with' => ['user_info']
];
$order = ['number'=>'DESC','createtime'=>'DESC'];
$order = ['createtime'=>'DESC'];
$model = new StoreComment();
$comment = $model->pageSelect($page,$where,'*',$order,config('option.num'));
$list = $comment->items();
... ... @@ -506,11 +562,55 @@ class Store extends Api
}
/**
* 留言消息
* @ApiWeigh (50)
* 留言消息详情
* @ApiWeigh (23)
*
* @ApiTitle (留言消息)
* @ApiSummary (留言消息)
* @ApiTitle (留言消息详情)
* @ApiSummary (留言消息详情)
* @ApiMethod (POST)
* @ApiRoute (/api/store/comment_detail)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="comment_id", type="integer", required=true, description="留言id")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": {
"comment": [
{
"id": 1,
"name": "行业名称",
"weigh": 0,
}
]
}
})
*/
public function comment_detail()
{
if($this->request->isPost()){
$param = (new StoreValidate())->goCheck('comment_detail');
$store = $this->get_store();
$where = [
'where' => ['id'=>$param['comment_id']],
'with' => ['user_info']
];
$model = new StoreComment();
$comment = $model->findOrFail($where,'*');
$return = [
'comment' => $comment
];
$this->success('请求成功',$return);
}
}
/**
* 留言回复
* @ApiWeigh (22)
*
* @ApiTitle (留言回复)
* @ApiSummary (留言回复)
* @ApiMethod (POST)
* @ApiRoute (/api/store/comment_reply)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
... ... @@ -561,29 +661,26 @@ class Store extends Api
'code':'1',
'msg':'返回成功',
"data": {
"list": [
{
"id": 1,
"name": "行业名称",
"weigh": 0,
}
]
"list": [
{
"id": 1,
"money": "充值金额",
"score": "赠送板币",
"weigh": 1,
},
]
}
})
*/
public function deposit()
{
if($this->request->isPost()){
$keyword = $this->request->param('keyword','');
$where = [
'where' => []
];
if($keyword) {
$where['where'] = ['name'=>['like','%'.$keyword.'%']];
}
$indus = $this->industry_model->selectOrFail($where,false,'*','weigh');
$deposit = $this->deposit_model->selectOrFail($where,false,'*','weigh');
$return = [
'list' => $indus,
'list' => $deposit,
];
$this->success('请求成功',$return);
}
... ... @@ -635,6 +732,7 @@ class Store extends Api
$order_result = $payment->pay($order);
if($order_result['return_code'] == 'SUCCESS' && $order_result['result_code'] == 'SUCCESS') {
$prepayId = $order_result->prepay_id;
$pay_data = $payment->configForJSSDKPayment($prepayId); // 返回数组
} else {
$this->error($order_result['return_msg']);
}
... ...
<?php
namespace app\api\interfaces;
interface HookProvidersInterface{
public function getProviders();
}
\ No newline at end of file
... ...
<?php
namespace app\api\interfaces;
interface UserInterface{
public function chi($params);
public function he($params);
public function la($params);
public function sa($params);
}
... ...
<?php
namespace app\api\library\Exception;
use think\Exception;
class BaseException extends Exception{
public $code = -1;
public $msg ='参数错误';
public $errCode = 200;
public function __construct($params=[]) {
if(!is_array($params)){
return ;
// throw new Exception('参数必须是数组');
}
if(array_key_exists('code',$params)){
$this->code = $params['code'];
}
if(array_key_exists('msg',$params)){
$this->msg = $params['msg'];
}
if(array_key_exists('errCode',$params)){
$this->errCode = $params['errCode'];
}
}
}
... ...
<?php
namespace app\api\library\Exception;
use Throwable;
class DataMissException extends BaseException {
public $code = -1;
public $msg ='数据查询不到';
public $errCode = 200;
public function __construct($message = "", $code = 0, Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
if(!empty($message)){
$this->message = $message;
}
}
}
... ...
<?php
namespace app\api\library\Exception;
class ParamsException extends BaseException {
public $code = 200;
public $msg = '参数错误';
public $errCode = 10000;
}
\ No newline at end of file
... ...
<?php
namespace app\api\providers;
use app\api\interfaces\HookProvidersInterface;
class HookProviders implements HookProvidersInterface {
static private $providers;
static private $instance;
public static function getInstance()
{
//判断$instance是否是Singleton的对象,不是则创建
if (!self::$instance instanceof self) {
self::$instance = new self();
}
return self::$instance;
}
public function getProviders(){
self::$providers = [
'user'=>[
'user_init' => [
'app\\api\\behavior\\user\\User',
],
]
];
return self::$providers;
}
}
\ No newline at end of file
... ...
<?php
namespace app\api\services;
use app\api\interfaces\UserInterface;
class UserServices implements UserInterface{
public function chi($params)
{
// TODO: Implement chi() method.
}
public function he($params)
{
// TODO: Implement chi() method.
}
public function la($params)
{
// TODO: Implement chi() method.
}
public function sa($params)
{
// TODO: Implement chi() method.
}
}
... ...
... ... @@ -36,6 +36,7 @@ class StoreValidate extends BaseValidate
'store_inform_add' => ['content','images','house_ids','type'], // 发布信息
'red' => ['red_package','number'], // 发布信息红包
'house_new' => ['house_ids'], // 绑定社区
'comment_detail' => ['comment_id'], // 留言详情
'comment_reply' => ['comment_id','content'], // 留言回复
'deposit_order' => ['deposit_id'], // 板币充值提交
];
... ...
... ... @@ -49,7 +49,68 @@ class Ajax extends Frontend
}
/**
* 支付结果回调
* 支付回调
*/
public function notify(){
$app = new Application(ConfigService::load());
$response = $app->payment->handleNotify(function($notify, $successful){
/*这里是支付回调逻辑处理,一下是DEMO*/
// 使用通知里的 "微信支付订单号" 或者 "商户订单号" 去自己的数据库找到订单
$out_trade_no=$notify->out_trade_no;
$info = Db::name('deposit_order')->where(['order_sn'=>$out_trade_no])->find();
if (!$info) { // 如果订单不存在
return 'Order not exist.'; // 告诉微信,我已经处理完了,订单没找到,别再通知我了
}
// 检查订单是否已经更新过支付状态
if ($info['transaction_id']) { // 假设订单字段“支付时间”不为空代表已经支付
return true; // 已经支付成功了就不再更新了
}
// 用户是否支付成功
if ($successful) {
Db::startTrans();
// 回填微信的订单号
$update['transaction_id'] = $notify->transaction_id;
$update['status'] = 0; //付款成功,接单中
$update['pay_time'] = time();
//更新状态: 已购买
$res_order = Db::name('deposit_order')->where(['id' => $info['id']])->update($update);
$user = Db::name('user')->where('id',$info['user_id'])->find();
//记录钱包log
$insert_data = array(
'user_id' => $info['user_id'],
'score' => $info['score'],
'before' => $user['score'],
'after' => $user['score'] + $info['score'],
'createtime' => time(),
'memo' => '充值',
);
$res_log = Db::name('user_score_log')->insert($insert_data);
// 增加用户板币余额
$res_user = Db::name('user')->where('id',$info['user_id'])->setInc('score',$info['score']);
if(!$res_order || !$res_log || !$res_user) {
Db::rollback();
return false; // 返回处理完成
}
Db::commit();
} else {
// 用户支付失败
$update['transaction_id'] = $notify->transaction_id;
$update['status'] = 6; //异常-支付失败
Db::name('deposit_order')->where(['id' => $info['id']])->update($update);
return false; // 返回处理完成
}
return true; // 返回处理完成
});
$response->send();
}
/**
* 商家入驻支付结果回调
*/
public function callback_for_wxgzh(){
$this->init_wx_pay_for_gzh(false);
... ...
此 diff 太大无法显示。
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'deposit/deposit/index' + location.search,
add_url: 'deposit/deposit/add',
edit_url: 'deposit/deposit/edit',
del_url: 'deposit/deposit/del',
multi_url: 'deposit/deposit/multi',
table: 'deposit',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'weigh',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'money', title: __('Money'), operate:'BETWEEN'},
{field: 'score', title: __('Score'), operate:'BETWEEN'},
{field: 'weigh', title: __('Weigh')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
\ No newline at end of file
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'deposit/deposit_order/index' + location.search,
add_url: 'deposit/deposit_order/add',
edit_url: 'deposit/deposit_order/edit',
del_url: 'deposit/deposit_order/del',
multi_url: 'deposit/deposit_order/multi',
table: 'deposit_order',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'order_sn', title: __('Order_sn')},
{field: 'user_id', title: __('User_id')},
{field: 'deposit_id', title: __('Deposit_id')},
{field: 'score', title: __('Score'), operate:'BETWEEN'},
{field: 'money', title: __('Money'), operate:'BETWEEN'},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
{field: 'pay_time', title: __('Pay_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'transaction_id', title: __('Transaction_id')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'user.nickname', title: __('User.nickname')},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
\ No newline at end of file
... ...
... ... @@ -34,7 +34,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'name', title: __('Name')},
{field: 'mobile', title: __('Mobile')},
{field: 'license', title: __('License'),operate: false,events:Table.api.events.image,formatter: Table.api.formatter.image},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3')}, formatter: Table.api.formatter.status},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4')}, formatter: Table.api.formatter.status},
{field: 'pay_time', title: __('Pay_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
// {field: 'province', title: __('Province')},
// {field: 'city', title: __('City')},
... ... @@ -51,7 +51,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
icon: 'fa fa-edit',
url: $.fn.bootstrapTable.defaults.extend.examine_url,
visible:function (row) {
if(row.status == 1){
if(row.status == 2){
return true;
}else{
return false;
... ...