123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?php
- namespace Code\Lib;
- use Dever;
- class Manage
- {
- public function showCode($id)
- {
- $info = Dever::db('code/info')->one($id);
- if ($info['code']) {
- return $info['code'];
- }
-
- /*
- if ($info['create_uid'] > 0) {
- return Dever::load('code/lib/core')->view($info['id'], true);
- return '用户创建';
- }
- */
- if ($info['product_id'] > 0) {
- return Dever::load('code/lib/core')->view($info['id'], true);
- }
- return 'T' . $id;
- }
- /**
- * 显示用户信息
- *
- * @return mixed
- */
- public function showUserInfo($teacher_id, $ldate = false, $type = 1)
- {
- $table = array();
- if ($type == 3 && $teacher_id && $teacher_id > 0) {
- $user = Dever::load('teacher/info-one', $uid);
- if ($user) {
- $table['讲师名称'] = $user['name'] . '('.$uid.')';
- $table['手机号'] = $user['mobile'];
- $table['使用时间'] = date('Y-m-d H:i:s', $ldate);
- }
- }
- return Dever::table($table);
- }
- /**
- * 创建兑换码
- *
- * @return mixed
- */
- public function create($id, $name, $param)
- {
- $code = Dever::param('num', $param);
- $product = Dever::param('product', $param);
- $cate_id = $product_id = 0;
- if ($product && isset($product[0])) {
- $cate_id = $product[0];
- if (isset($product[1])) {
- $product_id = $product[1];
- }
-
- $product = implode(',', $product);
- }
- if ($cate_id <= 0){
- Dever::alert('生成失败,请选择分类');
- }
- $total = 0;
- $core = Dever::load('code/lib/core');
- if ($code > 0 && $code > $total) {
- $num = $code - $total;
- $core->createCode($product, $cate_id, $product_id, 1, $num);
- }
- }
- /**
- * 作废
- *
- * @return mixed
- */
- public function drop_api($id, $journal_id, $code)
- {
- if (!$code && $journal_id > 0) {
- Dever::setInput('set_product_id', $journal_id);
- }
-
- $update['where_id'] = $id;
- $update['type'] = 4;
- Dever::db('code/info')->update($update);
- return 'ok';
- }
- public function recovery_api($id, $journal_id, $code)
- {
- if (!$code && $journal_id > 0) {
- Dever::setInput('set_product_id', $journal_id);
- }
- $update['where_id'] = $id;
- $update['type'] = 1;
- Dever::db('code/info')->update($update);
- return 'ok';
- }
- }
|