作者 郭盛
1 个管道 的构建 通过 耗费 8 秒

修改订单以及积分明细

此 diff 太大无法显示。
... ... @@ -20,6 +20,18 @@ use think\Validate;
*/
class OrderController extends RestBaseController
{
public function _initialize()
{
$user_id = $this->getUserId();
$data = Db::name('integral')
->where('user_id',$user_id)
->find();
if(empty($data)){
$this->error(['code'=>40005,'msg'=>'请先注册']);
}
}
/**
* @title 创建订单
* @description
... ... @@ -36,12 +48,6 @@ class OrderController extends RestBaseController
*/
public function createOrder(){
$user_id = $this->getUserId();
$data = Db::name('integral')
->where('user_id',$user_id)
->find();
if(empty($data)){
$this->error('请先注册!');
}
$total = $this->request->param('total');
$pay_id = $this->request->param('pay_id');
if(empty($total)){
... ... @@ -107,4 +113,53 @@ class OrderController extends RestBaseController
return $openid;
}
/**
* @title 提现
* @author Guosheng
* @url /index/order/pay
* @method GET
*
* @header name:XX-Token require:1 default: desc:token
*
* @param name:order_id type:int require:1 other: desc:订单id
*/
public function deposit()
{
$id = $this->getUserId();
}
/**
* @title 积分明细
* @description
* @author GuoSheng
* @url /index/Order/detail
* @method GET
*
* @header name:XX-Token require:1 default: desc:token
*
* @param name:page type:int require:0 other: desc:当前页(默认1)
* @param name:pageNum type:int require:0 other: desc:每页显示数据个数(默认10)
*
* @return type:类型(1充值,2兑换商品,3获得奖励,4提现)
* @return total: 变动的积分
* @return create_time: 创建时间
*/
public function detail()
{
$user_id = $this->getUserId();
$page = $this->request->param('page',1,'intval');
$pageNum = $this->request->param('pageNum',10,'intval');
$list = Db::name('detail')
->where('user_id',$user_id)
->field('id,user_id,type,total,create_time')
->page($page,$pageNum)
->select();
foreach ($list as &$v){
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
}
$this->success('SUCCESS',$list);
}
}
\ No newline at end of file
... ...
... ... @@ -95,15 +95,17 @@ class PayController extends HomeBaseController
$list = Db::name('integral')
->where('user_id',$order['user_id'])
->find();
$res['now'] = $list['now'];
$res['before_wallet'] = $list['before_wallet'];
$res['before_wallet'] = $list['now_integral'];
$res['total'] = $arr['integral'];
$res['after_wallet'] = $arr['before_wallet'] + $arr['integral'];
$res['add_total'] = $res['add_total'] + $arr['integral'];
$res['type'] = 1;
Db::name('integral')
Db::name('detail')
->where('user_id',$order['user_id'])
->update($res);
$after_wallet = $res['after_wallet'];
Db::name('integral')
->where('user_id',$order['user_id'])
->update(['now_integral'=>$after_wallet]);
} else { // 用户支付失败
$update['status']=1;
}
... ... @@ -145,5 +147,32 @@ class PayController extends HomeBaseController
return $url;
}
/**
* 微信提现
* @param $data
* @return mixed
*/
public function tixian($data)
{
$merchantPayData = [
'partner_trade_no' => $data['num'], //随机字符串作为订单号,跟红包和支付一个概念。
'openid' => $data['openid'], //收款人的openid
'check_name' => 'NO_CHECK', //文档中有三种校验实名的方法 NO_CHECK OPTION_CHECK FORCE_CHECK
're_user_name'=>'', //OPTION_CHECK FORCE_CHECK 校验实名的时候必须提交
'amount' => (1-0.006)*$data['total']*100, //单位为分
'desc' => '提现',
'spbill_create_ip' => '192.168.0.1', //发起交易的IP地址
];
$app = new Application($this->options);
$merchantPay = $app->merchant_pay;
$result = $merchantPay->send($merchantPayData);
if ($result->return_code == 'SUCCESS' && $result->result_code == 'SUCCESS') {
return $result->code_url;
} else {
$this->error('支付参数错误', '', $result);
}
}
}
\ No newline at end of file
... ...
... ... @@ -192,22 +192,4 @@ class UserController extends RestBaseController
$this->success('SUCCESS',$data);
}
/**
* @title 提现
* @author Guosheng
* @url /index/order/pay
* @method GET
*
* @header name:XX-Token require:1 default: desc:token
*
* @param name:order_id type:int require:1 other: desc:订单id
*/
public function deposit()
{
$id = $this->getUserId();
}
}
\ No newline at end of file
... ...