1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace Code\Lib;
- use Dever;
- class Manage
- {
- /**
- * 显示用户信息
- *
- * @return mixed
- */
- public function showUserInfo($create_uid, $uid, $ldate = false)
- {
- $table = array();
- if ($create_uid && $create_uid > 0) {
- $user = Dever::load('passport/user-one', $create_uid);
- $table['创建人'] = $user['username'];
- }
- if ($uid && $uid > 0) {
- $user = Dever::load('passport/user-one', $uid);
- if ($user) {
- $table['领取人'] = $user['username'];
- $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_num = Dever::param('product_num', $param);
- $product = Dever::param('product', $param);
- //$product_id = Dever::param('product_id', $param);
- $seller_id = Dever::param('seller_id', $param);
- $cate_id = $product_id = 0;
- if ($product && isset($product[0]) && isset($product[1])) {
- $cate_id = $product[0];
- $product_id = $product[1];
- $product = implode(',', $product);
- }
- if ($cate_id <= 0 || $product_id <= 0){
- Dever::alert('生成失败');
- }
- //$total = Dever::db('code/info')->total(array('product_id' => $product_id, 'type' => 1));
- $total = 0;
- $core = Dever::load('code/lib/core');
- if ($code > 0 && $code > $total) {
- $num = $code - $total;
- for ($i = 0; $i < $num; $i++) {
- $core->createCode($product, $cate_id, $product_id, $seller_id, $product_num);
- }
- }
- }
- }
|