作者 景龙
1 个管道 的构建 通过 耗费 10 秒

增加提交废品表单审核通过之后增加积分

... ... @@ -108,12 +108,14 @@ class Porder extends Backend
if ($ids) {
$pk = $this->model->getPk();
$res = $this->model->where($pk, '=', $ids)->find();
Db::startTrans();
if ($res['is_due'] == 0) {
$data = $this->model->where($pk, '=', $ids)->find();
$userModel = new User();
$money = (1 - $this->percent) * $data['total_price'];
//用户账户增加余额
$result = $userModel->where(['id'=>$data['s_uid'],'status'=>'normal'])->setInc('money',$money);
//平台账户增加余额
$platformModel = new Platform();
$account_balance = $this->percent * $data['total_price'];
... ... @@ -121,8 +123,10 @@ class Porder extends Backend
//订单更新扣取费用字段
$result2 = $this->model->where($pk, '=', $ids)->update(['is_due'=>1]);
if($result && $result1 && $result2){
Db::commit();
$this->success('扣取成功');
}else{
Db::rollback();
$this->error('扣取失败');
}
} else {
... ...
... ... @@ -3,7 +3,8 @@
namespace app\admin\controller;
use app\common\controller\Backend;
use app\admin\model\User;
use think\Db;
/**
* 卖废品管理
*
... ... @@ -74,4 +75,44 @@ class Sell extends Backend
}
return $this->view->fetch();
}
//审核通过
public function adopt($ids){
if ($ids) {
$pk = $this->model->getPk();
$result2 = $this->model->where($pk, '=', $ids)->update(['status' => 1]);
//给自己增加积分
$data = $this->model->where($pk, '=', $ids)->find();
$userModel = new User();
$scoreRule = Db::name('score')
->where('set_rule', 'like', '%卖废品%')
->field('set_score')
->find();
$score = 0;
if ($scoreRule) {
$score = $scoreRule['set_score'];
}
$result = $userModel->where(['id' => $data['uid'], 'status' => 'normal'])->setInc('score', $score);
if ($result2 && $result) {
$this->success('成功');
} else {
$this->error('失败');
}
}
$this->error(__('Parameter %s can not be empty', 'ids'));
}
//审核驳回
public function reject($ids){
if ($ids) {
$pk = $this->model->getPk();
$result2 = $this->model->where($pk, '=', $ids)->update(['status' => 2]);
if ($result2) {
$this->success('成功');
} else {
$this->error('失败');
}
}
$this->error(__('Parameter %s can not be empty', 'ids'));
}
}
... ...
... ... @@ -66,6 +66,9 @@ return [
'pre_list' => '预约单',
'purchase' => '购买',
'in_audit' => '审核中',
'adopt' => '通过',
'reject' => '驳回',
'Locked' => '锁定',
'Submit' => '提交',
... ...
... ... @@ -8,6 +8,7 @@ return [
'Pre_time' => '预约时间',
'Images' => '废品图片',
'Description' => '废品描述',
'status' => '状态',
'Createtime' => '创建时间',
'User.username' => '用户名',
'User.avatar' => '头像'
... ...
... ... @@ -62,8 +62,8 @@ class Sell extends Api
$data['images'] = $sell_data['images'];
$data = $sell::create($data);
//给自己增加积分
$data1 = $person->getPersonScore('person_sell');
if($data && $data1){
// $data1 = $person->getPersonScore('person_sell');
if($data){
$this->success('保存成功');
}else{
$this->error('保存失败');
... ...
... ... @@ -45,11 +45,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
text: __('完成'),
title: __('完成'),
classname: 'btn btn-xs btn-success btn-magic btn-ajax',
icon: 'fa fa-magic',
icon: 'fa',
url: 'porder/finish',
confirm: '确认完成',
success: function (data, ret) {
Layer.alert(ret.msg);
$(".btn-refresh").trigger("click");
//如果需要阻止成功提示,则必须使用return false;
//return false;
},
... ...
... ... @@ -31,8 +31,60 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'address', title: __('Address')},
{field: 'pre_date', title: __('Pre_date'), operate:'RANGE', addclass:'datetimerange'},
{field: 'pre_time', title: __('Pre_time')},
{field: 'status', title: __('status'), formatter: Table.api.formatter.flag,searchList: {0: __('in_audit'), 1: __('adopt'),2: __('reject')}},
{field: 'createtime', title: __('Createtime'), 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}
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons: [
{
name: 'ajax',
text: __('通过'),
title: __('通过'),
classname: 'btn btn-xs btn-success btn-magic btn-ajax',
icon: 'fa',
url: 'sell/adopt',
confirm: '确认通过',
success: function (data, ret) {
Layer.alert(ret.msg);
$(".btn-refresh").trigger("click");
//如果需要阻止成功提示,则必须使用return false;
//return false;
},
error: function (data, ret) {
Layer.alert(ret.msg);
return false;
},visible: function (row) {
if(row.status == 1){
return false;//隐藏
}else{
return true;
}
}
},
{
name: 'ajax',
text: __('驳回'),
title: __('驳回'),
classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
icon: 'fa',
url: 'sell/reject',
confirm: '确认驳回',
success: function (data, ret) {
Layer.alert(ret.msg);
$(".btn-refresh").trigger("click");
//如果需要阻止成功提示,则必须使用return false;
//return false;
},
error: function (data, ret) {
Layer.alert(ret.msg);
return false;
},visible: function (row) {
if(row.status == 2){
return false;//隐藏
}else{
return true;
}
}
}
]}
]
]
});
... ...