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

合并分支 'liuzhen' 到 'master'

Liuzhen



查看合并请求 !46
... ... @@ -141,13 +141,13 @@ class UserWithdraw extends Backend
// 余额变动记录
$log = [
'user_id' => $row->user_id,
'money' => $row->money,
'score' => $row->money,
'before' => $user['money'],
'after' => $user['money'] - $row->money,
'createtime' => time(),
'memo' => '用户微信提现'
];
$result_log = Db::name('user_money_log')->insertGetId($log);
$result_log = Db::name('user_score_log')->insertGetId($log);
$row->success_time = time();
$row->more = json_encode($result_pay, JSON_UNESCAPED_UNICODE);
} else {
... ... @@ -155,9 +155,19 @@ class UserWithdraw extends Backend
$this->error($result_pay['err_code_des']);
}
} else {
// 余额变动记录
$log = [
'user_id' => $row->user_id,
'score' => $row->money,
'before' => $user['score'],
'after' => $user['score'] + $row->money,
'createtime' => time(),
'memo' => '提现审核失败'
];
$result_log = Db::name('user_score_log')->insertGetId($log);
// 返还用户余额
$result_user = $user_model->where('id', $user['id'])->setInc('money', $row->money);
if (!$result_user) {
$result_user = $user_model->where('id', $user['id'])->setInc('score', $row->money);
if (!$result_log || !$result_user) {
Db::rollback();
$this->error('提现审核失败');
}
... ...
... ... @@ -21,6 +21,7 @@ return [
'City' => '市',
'Region' => '区',
'Images' => '宣传图',
'Content' => '店铺详情',
'Createtime' => '生成时间',
'Updatetime' => '更新时间',
'Admin.nickname' => '昵称',
... ...
<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>
<label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</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">{:__('House_ids')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-house_ids" data-rule="required" data-source="house/index" data-multiple="true" class="form-control selectpage" name="row[house_ids]" type="text" value="{$row.house_ids|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Store_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-store_name" data-rule="required" class="form-control" name="row[store_name]" type="text" value="{$row.store_name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Industry_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-industry_id" data-rule="required" data-source="industry/index" class="form-control selectpage" name="row[industry_id]" type="text" value="{$row.industry_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-mobile" data-rule="required" class="form-control" name="row[mobile]" type="text" value="{$row.mobile|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('License')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-license" data-rule="required" class="form-control" name="row[license]" type="text" value="{$row.license|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" data-rule="required" 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">
<label class="control-label col-xs-12 col-sm-2">{:__('Store_icon')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-store_icon" class="form-control" name="row[store_icon]" type="text" value="{$row.store_icon|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Province')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-province" class="form-control" name="row[province]" type="text" value="{$row.province|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('City')}:</label>
<div class="col-xs-12 col-sm-8">
<div class='control-relative'><input id="c-city" class="form-control" data-toggle="city-picker" name="row[city]" type="text" value="{$row.city|htmlentities}"></div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Region')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-region" class="form-control" name="row[region]" type="text" value="{$row.region|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-images" class="form-control" size="50" name="row[images]" type="textarea" value="{$row.images|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-images" class="btn btn-danger plupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-images"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-images"></ul>
<textarea name="row[content]" id="" class="form-control editor" cols="30" rows="10">{$row.content|htmlentities}</textarea>
</div>
</div>
<div class="form-group layer-footer">
... ...
... ... @@ -97,6 +97,7 @@ class Goods extends Api
* @ApiMethod (POST)
* @ApiRoute (/api/goods/goods_list)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="store_id", type="integer", required=false, description="店铺id")
* @ApiParams (name="keyword", type="string", required=false, description="关键词")
* @ApiParams (name="page", type="integer", required=true, description="页数")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
... ... @@ -141,6 +142,9 @@ class Goods extends Api
if(!empty($param['keyword'])) {
$basic_where['goods_name'] = ['like','%'.$param['keyword'].'%'];
}
if(!empty($param['store_id'])) {
$basic_where['store_id'] = $param['store_id'];
}
$where = [
'where' => $basic_where,
];
... ...
... ... @@ -9,7 +9,10 @@ use app\api\model\Industry;
use app\api\model\StoreComment;
use app\api\model\StoreInform;
use app\api\model\StoreInformGood;
use app\api\model\StoreInformLog;
use app\api\model\StoreInformView;
use app\api\model\UserHouse;
use app\api\model\UserMoneyLog;
use app\api\validate\HotValidate;
use app\common\controller\Api;
use think\Db;
... ... @@ -32,7 +35,6 @@ class Hot extends Api
protected $favorite_model;
protected $comment_model;
protected $good_model;
protected $follow_model;
protected $user_id;
public function __construct(Request $request,\app\api\model\Store $store,Industry $industry,StoreInform $store_inform,UserHouse $user_house,StoreInformGood $store_inform_good)
... ... @@ -55,6 +57,7 @@ class Hot extends Api
* @ApiMethod (POST)
* @ApiRoute (/api/hot/store_list)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="store_id", type="integer", required=false, description="店铺id")
* @ApiParams (name="page", type="integer", required=true, description="页数")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
... ... @@ -100,8 +103,12 @@ class Hot extends Api
{
if($this->request->isPost()){
$page = $this->request->param('page',1,'intval');
$this->store_id = $this->request->param('store_id',0,'intval');
$house_ids = $this->user_house_model->where('user_id',$this->user_id)->column('house_id');
$query = function ($query) use ($house_ids){
if($this->store_id) {
$query->where('store_id',$this->store_id);
}
foreach ($house_ids as $k=>$v){
$w = ['house_ids'=>['like','%,'.$v.',%']];
if($k == 0) {
... ... @@ -118,6 +125,7 @@ class Hot extends Api
$order = ['number'=>'DESC','createtime'=>'DESC'];
$inform = $this->store_inform_model->pageSelect($page,$where,'*',$order,config('option.num'));
$list = $inform->items();
$view_model = new StoreInformView();
foreach ($list as &$v) {
// 获取点赞数及是否点赞
$where_g = [
... ... @@ -126,6 +134,24 @@ class Hot extends Api
$v['good_count'] = $this->store_inform_good_model->getCount($where_g);
$where_g['user_id'] = $this->user_id;
$v['is_good'] = $this->store_inform_good_model->getCount($where_g);
// 记录浏览量
$where_v = [
'user_id' => $this->auth->id,
'object_id' => $v['id']
];
$view = $view_model->where($where_v)->find();
if($view) {
$where_v = [
'id' => $view['id']
];
$view_model->where($where_v)->setInc('count');
} else {
$insert = [
'user_id' => $this->auth->id,
'object_id' => $v['id']
];
$view_model->add($insert);
}
}
$return = [
'list' => $list,
... ... @@ -137,6 +163,185 @@ class Hot extends Api
}
/**
* 商圈店铺主页
* @ApiWeigh (75)
*
* @ApiTitle (商圈店铺主页)
* @ApiSummary (商圈店铺主页)
* @ApiMethod (POST)
* @ApiRoute (/api/hot/store_detail)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="store_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": {
"store": {
"id": 1,
"user_id": 1,
"store_name": "店铺名称",
"industry_id": "行业标签",
"name": "测试11",
"mobile": "联系电话",
"store_icon": "图标",
"province": "地址省",
"city": "市",
"region": "区",
"images": "/assets/img/qrcode.png,/assets/img/qrcode.png",
"content": "店铺详情",
"image_arr"店铺轮播: [
"http://cloud.caiyunpan.brotop.cn/assets/img/qrcode.png",
"http://cloud.caiyunpan.brotop.cn/assets/img/qrcode.png"
]
}
}
})
*/
public function store_detail()
{
if($this->request->isPost()){
$store_id = $this->request->param('store_id',0,'intval');
$where = [
'where' => ['id'=>$store_id]
];
$store = $this->store_model->findOrFail($where);
$return = [
'store' => $store
];
$this->success('请求成功',$return);
}
}
/**
* 领取红包
* @ApiWeigh (60)
*
* @ApiTitle (领取红包)
* @ApiSummary (领取红包)
* @ApiMethod (POST)
* @ApiRoute (/api/hot/get_red_package)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="store_inform_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": {
}
})
*/
public function get_red_package()
{
if($this->request->isPost()){
$param = (new HotValidate())->goCheck('get_red_package');
$where = [
'where' => ['id'=>$param['store_inform_id']]
];
$inform = $this->store_inform_model->findOrFail($where);
if($inform['surplus'] == 0) {
$this->error('红包已抢完');
}
$log_model = new StoreInformLog();
$user_model = new \app\api\model\User();
$money_log_model = new UserMoneyLog();
$where_l = [
'where' => [
'user_id' => $this->auth->id,
'inform_id' => $inform['id'],
]
];
$log = $log_model->findOrFail($where_l,false);
if($log) {
$this->error('已领取过该商圈红包');
}
Db::startTrans();
// 录入领取记录
$log_data = [
'user_id' => $this->auth->id,
'inform_id' => $inform['id'],
'money' => $inform['single']
];
$res_log = $log_model->add($log_data);
// 新增用户余额
$res_user = $user_model->where('id',$this->auth->id)->setInc('money',$inform['single']);
// 新增余额记录
$money_log_data = [
'user_id' => $this->auth->id,
'money' => $inform['single'],
'before' => $this->auth->money,
'after' => bcadd($this->auth->money,$inform['single'],2),
'memo' => '领取红包'
];
$res_moeny_log = $money_log_model->add($money_log_data);
if(!$res_log || !$res_user || !$res_moeny_log) {
Db::rollback();
$this->error('红包领取失败');
}
Db::commit();
$this->success('领取成功');
}
}
/**
* 留言列表
* @ApiWeigh (50)
*
* @ApiTitle (留言列表)
* @ApiSummary (留言列表)
* @ApiMethod (POST)
* @ApiRoute (/api/hot/comment_list)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="store_id", type="integer", required=true, description="店铺id")
* @ApiParams (name="page", type="integer", 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 comment_list()
{
$param = (new HotValidate())->goCheck('common');
$where = [
'where' => ['store_id' => $param['store_id']]
];
$model = new StoreComment();
$order = ['createtime'=>'DESC'];
$comment = $model->pageSelect($param['page'],$where,'*',$order,config('option.num'));
$list = $comment->items();
if($list) {
foreach ($list as &$v) {
$v['is_self'] = $v['type'] == 1 ? 1 : 0;
if($v['is_self'] == 1) {
$user = $this->auth->getUserinfo();
$v['nickname'] = $user['nickname'];
$v['avatar'] = $user['avatar'];
} else {
$where_s = [
'where' => [
'id' => $v['store_id']
]
];
$store = $this->store_model->findOrFail($where_s,false,'id,store_name as nickname,store_icon as avatar');
$v['nickname'] = $store['nickname'];
$v['avatar'] = cdnurl($store['avatar']);
}
}
// $list = array_sort($list,'id',SORT_ASC);
}
$return = [
'list' => $list,
'this_page' => $comment->currentPage(),
'total_page' => $comment->lastPage()
];
$this->success('成功',$return);
}
/**
* 留言提交
* @ApiWeigh (50)
*
... ...
... ... @@ -852,6 +852,7 @@ class Store extends Api
if (!$validate->check($param)) {
$this->error($validate->getError());
}
$withdraw_percent = config('site.withdraw_percent');
if ($param['money'] < 1) {
$this->error('提现金额不可小于1元');
}
... ... @@ -859,8 +860,8 @@ class Store extends Api
$this->error('提现金额不可大于1000元');
}
// 判断余额是否充足
if ($param['money'] > $this->auth->money) {
$this->error('桃币余额不足,无法提现');
if ($param['money'] * $withdraw_percent > $this->auth->money) {
$this->error('余额不足,无法提现');
}
// 提现记录
Db::startTrans();
... ... @@ -870,24 +871,24 @@ class Store extends Api
$order_sn = date('YmdHis').rand(0000,9999);
$withdraw = [
'user_id' => $this->auth->id,
'before_money' => $this->auth->money,
'after_money' => $this->auth->money - $param['money'],
'before_money' => $this->auth->score,
'after_money' => $this->auth->score - $param['money'] * $withdraw_percent,
'order_sn' => $order_sn,
'money' => $param['money'],
];
$result = $withdraw_model->isUpdate(false)->save($withdraw);
// 记录用户余额
$result_user = $user_model->isUpdate(true)->save(['money' => $user['money'] - $param['money']]);
$result_user = $user_model->isUpdate(true)->save(['money' => $user['money'] - $param['money'] * $withdraw_percent]);
// 记录余额变更
$insert_data = array(
'user_id' => $this->auth->id,
'money' => $param['money'],
'before' => $this->auth->money,
'after' => $this->auth->money - $param['money'],
'score' => $param['money'],
'before' => $this->auth->score,
'after' => $this->auth->score - $param['money'] * $withdraw_percent,
'createtime' => time(),
'memo' => '提现',
);
$res_log = Db::name('user_money_log')->insert($insert_data);
$res_log = Db::name('user_score_log')->insert($insert_data);
if (!$result || !$result_user || !$res_log) {
Db::rollback();
$this->error('提现申请失败', [$result, $result_user]);
... ...
... ... @@ -19,7 +19,7 @@ class Store extends Base
public function getImageArrAttr($value,$data)
{
$arr = [];
if($data['images']) {
if(!empty($data['images'])) {
$arr = explode(',',$data['images']);
foreach ($arr as &$v) {
$v = cdnurl($v);
... ...
<?php
namespace app\api\model;
class StoreInformLog extends Base
{
}
\ No newline at end of file
... ...
<?php
namespace app\api\model;
class StoreInformView extends Base
{
}
\ No newline at end of file
... ...
... ... @@ -37,5 +37,7 @@ class HotValidate extends BaseValidate
'red' => ['red_package','number'], // 发布信息红包
'house_new' => ['house_ids'], // 绑定社区
'deposit_order' => ['deposit_id'], // 板币充值提交
'comment_list' => ['store_id','page'], // 留言列表
'get_red_package' => ['store_inform_id'], // 商家信息id
];
}
\ No newline at end of file
... ...
... ... @@ -371,4 +371,31 @@ if(!function_exists('get_order_sn')) {
$micro = explode('.',explode(' ',microtime())[0])[1];
return date('YmdHis').substr($micro,0,5).rand(0,9);
}
}
if(!function_exists('array_sort')) {
/**
* 二维数组排序
* @param $array
* @param $field
* @param $sort
*/
function array_sort($array,$field,$sort = 'SORT_DESC')
{
// 数组排序
$sort = array(
'direction' => $sort, //排序顺序标志 SORT_DESC 降序;SORT_ASC 升序
'field' => $field, //排序字段
);
$arrSort = array();
foreach ($array AS $uniqid => $row) {
foreach ($row AS $key => $value) {
$arrSort[$key][$uniqid] = $value;
}
}
if ($sort['direction']) {
array_multisort($arrSort[$sort['field']], $sort['direction'], $array);
}
return $array;
}
}
\ No newline at end of file
... ...
... ... @@ -41,10 +41,10 @@ class User extends Model
{
if (!$value) {
//如果不需要启用首字母头像,请使用
//$value = '/assets/img/avatar.png';
$value = letter_avatar($data['nickname']);
$value = '/assets/img/avatar.png';
// $value = letter_avatar($data['nickname']);
}
return $value;
return cdnurl($value);
}
/**
... ...
此 diff 太大无法显示。
... ... @@ -7,7 +7,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
extend: {
index_url: 'store/store/index' + location.search,
// add_url: 'store/store/add',
// edit_url: 'store/store/edit',
edit_url: 'store/store/edit',
del_url: 'store/store/del',
// multi_url: 'store/store/multi',
examine_url: 'store/store/examine',
... ... @@ -44,6 +44,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
buttons: [
{
name: 'edit',
text: '',
title: '编辑',
classname: 'btn btn-xs btn-success btn-editone',
icon: 'fa fa-edit',
url: $.fn.bootstrapTable.defaults.extend.edit_url,
visible:function (row) {
if(row.status == 3){
return true;
}else{
return false;
}
},
},
{
name: 'examine',
text: '审核',
title: '审核',
... ... @@ -66,6 +81,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 为表格绑定事件
Table.api.bindevent(table);
},
edit: function () {
Controller.api.bindevent();
},
examine: function () {
Controller.api.change();
Controller.api.bindevent();
... ...