12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace app\api\controller\mining;
- use app\models\mining\MiningMachine;
- use app\models\trade\CashTradeOrder;
- use app\Request;
- use crmeb\services\CacheService;
- use crmeb\services\UtilService;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\DbException;
- use think\db\exception\ModelNotFoundException;
- class MiningController
- {
-
- public function lst(Request $request)
- {
- $page = $request->get('page', 1);
- $limit = $request->get('limit', 10);
- return app('json')->success('ok', MiningMachine::getList($page, $limit));
- }
-
- public function detail($id, Request $request)
- {
- return app('json')->success('ok', MiningMachine::valid()->where('id', $id)->find()->toArray());
- }
- public function buy($id, Request $request)
- {
- $user = $request->user();
- list($num,) = UtilService::postMore(
- [
- ['num', 0,],
- ['trade_psw', '', '', '', ['not_empty_check', function ($item) use ($user) {
- return md5(md5($item)) == $user['trade_pwd'];
- }], ['请输入交易密码', '交易密码错误']],
- ], $request, true);
- $res = MiningMachine::buyMachine($id, $request->uid(), $num);
- if ($res) {
- return app('json')->success('购买成功');
- } else {
- return app('json')->fail(MiningMachine::getErrorInfo());
- }
- }
- }
|