1
This commit is contained in:
parent
c188bb96cb
commit
b533f4e73b
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\api\controller\food;
|
namespace app\api\controller\food;
|
||||||
|
|
||||||
use app\api\controller\food\Controller;
|
use app\api\controller\food\Controller;
|
||||||
@ -6,6 +7,7 @@ use app\api\model\food\User as UserModel;
|
|||||||
use app\api\model\Setting;
|
use app\api\model\Setting;
|
||||||
use hema\sms\Driver as Sms;
|
use hema\sms\Driver as Sms;
|
||||||
use think\facade\Cache;
|
use think\facade\Cache;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户管理
|
* 用户管理
|
||||||
@ -121,4 +123,52 @@ class User extends Controller
|
|||||||
return $this->renderError($error);
|
return $this->renderError($error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公众号 优惠券列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function getWxUserCoupon()
|
||||||
|
{
|
||||||
|
$post = $this->request->post();
|
||||||
|
$where = [
|
||||||
|
'openid' => $post['openid'],
|
||||||
|
];
|
||||||
|
if (isset($post['id'])) {
|
||||||
|
$where['coupon_user_id'] = $post['id'];
|
||||||
|
}
|
||||||
|
$data = Db::name('food_coupon_user_wx')->where($where)->select();
|
||||||
|
return $this->renderSuccess($data, '成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公众号 优惠券核销
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
$post = $this->request->post();
|
||||||
|
|
||||||
|
$user = Db::name('user_wx')->where(['wx_openid' => $post['openid']])->value('is_role');
|
||||||
|
if (empty($user) || $user == 0) {
|
||||||
|
return $this->renderError('你没核销权限');
|
||||||
|
}
|
||||||
|
|
||||||
|
$where = [
|
||||||
|
// 'openid' => $post['openid'],
|
||||||
|
'coupon_user_id' => $post['id'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$data = Db::name('food_coupon_user_wx')->where($where)->update(['status' => 2]);
|
||||||
|
return $this->renderSuccess($data, '成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user