Пример #1
0
 /**
  * 创建退账申请
  */
 function create()
 {
     $id = filter::int($this->post->id);
     $type = filter::int($this->post->type);
     $type = empty($type) ? 0 : 1;
     $reason = $this->post->reason;
     $money = filter::number($this->post->money);
     $money = empty($money) ? 0 : $money;
     if (empty($id) || empty($reason) || empty($money)) {
         return json_encode(array('code' => 5, 'result' => '参数不全'));
     }
     $description = $this->post->description;
     $description = empty($description) ? '' : $description;
     $imgs = array();
     if (isset($_FILES['img'])) {
         $image = new image();
         $imgs = $this->file->receiveMultiFile($_FILES['img'], config('file'));
         foreach ($imgs as &$img) {
             $img = $image->resizeImage($img, 640, 320);
         }
     }
     if (login::user()) {
         $orderModel = $this->model('orderlist');
         $order = $orderModel->get($id);
         if (empty($order)) {
             return json_encode(array('code' => 3, 'result' => '订单不存在'));
         }
         if (!in_array($order['status'], array(orderlistModel::STATUS_COMPLETE, orderlistModel::STATUS_PAYED, orderlistModel::STATUS_SHIPPED, orderlistModel::STATUS_SHIPPING))) {
             return json_encode(array('code' => 4, 'result' => '该订单不允许退款或者已经退款'));
         }
         $refundModel = $this->model('refund');
         if ($refundModel->create($this->session->id, $id, $type, $reason, $money, $description, $imgs)) {
             $orderModel->refund($id);
             return json_encode(array('code' => 1, 'result' => 'ok'));
         }
         return json_encode(array('code' => 0, 'result' => '申请失败'));
     }
     return json_encode(array('code' => 2, 'result' => '尚未登陆'));
 }
Пример #2
0
 /**
  * 创建优惠码
  */
 function create()
 {
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'coupon', roleModel::POWER_INSERT)) {
         $couponno = $this->post->couponno;
         $starttime = $this->post->starttime;
         $endtime = $this->post->endtime;
         $total = filter::int($this->post->total);
         $category = json_decode(htmlspecialchars_decode($this->post->category));
         $type = $this->post->type;
         $display = filter::int($this->post->display);
         $uid = filter::int($this->post->uid);
         $max = filter::number($this->post->max);
         $value = filter::number($this->post->value);
         $couponModel = $this->model('coupon');
         $result = $couponModel->create($couponno, $uid, $total, $starttime, $endtime, $max, $display, $type, $value);
         if ($result) {
             $this->model('coupondetail')->create($result, $category);
             return new json(json::OK);
         }
         return new json(json::PARAMETER_ERROR, '添加失败');
     }
     return new json(json::NO_POWER);
 }
Пример #3
0
 /**
  * 管理员添加o2o账户
  * @param post uid 不得为空
  */
 function create()
 {
     $this->response->addHeader('Content-Type', 'application/json');
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'o2ouser', roleModel::POWER_INSERT)) {
         $uid = filter::int($this->post->uid);
         $rate = filter::number($this->post->rate);
         $name = $this->post->name;
         $address = $this->post->address;
         $qq = $this->post->qq;
         if (empty($name) || empty($address) || empty($qq) || empty($rate)) {
             return json_encode(array('code' => 2, 'result' => '数据不全'));
         }
         $o2oModel = $this->model('o2ouser');
         if ($o2oModel->create($uid, $name, $qq, $address, $rate)) {
             return json_encode(array('code' => 1, 'result' => 'ok'));
         }
         return json_encode(array('code' => '3', 'result' => '添加失败'));
     } else {
         return json_encode(array('code' => 0, 'result' => '没有权限'));
     }
 }
Пример #4
0
 /**
  * 把商品添加到限时折扣中
  */
 function create()
 {
     $this->response->addHeader('Content-Type', 'application/json');
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'sale', roleModel::POWER_INSERT)) {
         $sname = $this->post->sname;
         $pid = filter::int($this->post->pid);
         $starttime = $this->post->starttime;
         $endtime = $this->post->endtime;
         $price = filter::number($this->post->price);
         $orderby = filter::int($this->post->orderby);
         $productModel = $this->model('product');
         $result = $productModel->get($pid);
         if (!empty($pid) && !empty($result) && empty($result['activity'])) {
             $saleModel = $this->model('sale');
             if ($saleModel->create($sname, $pid, $starttime, $endtime, $price, $orderby)) {
                 $productModel->setActivity($pid, 'sale');
                 return json_encode(array('code' => 1, 'result' => 'ok'));
             }
             return json_encode(array('code' => 2, 'result' => '添加失败,该商品已经在限时队列'));
         }
         switch ($result['activity']) {
             case 'seckill':
                 $result = '秒杀';
                 break;
             case 'sale':
                 $result = '满减';
                 break;
             case 'fullcut':
                 $result = '满减';
                 break;
         }
         return json_encode(array('code' => 3, 'result' => '该商品已经参加了' . $result . '活动,请先移除原来的活动在推送'));
     }
     return json_encode(array('code' => 4, 'result' => '没有权限'));
 }
Пример #5
0
 /**
  * 创建满减活动规则
  */
 function create()
 {
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'fullcut', roleModel::POWER_INSERT)) {
         $id = filter::int($this->post->id);
         $name = $this->post->name;
         $max = filter::number($this->post->max);
         $minus = filter::number($this->post->minus);
         $starttime = $this->post->starttime;
         $endtime = $this->post->endtime;
         if (empty($name) || empty($max) || empty($minus) || empty($starttime) || empty($endtime)) {
             return json_encode(array('code' => 0, 'result' => '参数不全'));
         }
         $fullcutModel = $this->model('fullcut');
         if (empty($id)) {
             if ($fullcutModel->create($name, $max, $minus, $starttime, $endtime)) {
                 return json_encode(array('code' => 1, 'result' => '创建成功'));
             } else {
                 return json_encode(array('code' => 2, 'result' => '创建失败'));
             }
         } else {
             if ($fullcutModel->save($id, $name, $max, $minus, $starttime, $endtime)) {
                 return json_encode(array('code' => 1, 'result' => '保存成功'));
             } else {
                 return json_encode(array('code' => 2, 'result' => '保存失败'));
             }
         }
     } else {
         return json_encode(array('code' => 3, 'result' => '权限不足'));
     }
 }
Пример #6
0
 /**
  * 创建秒杀活动
  */
 function create()
 {
     $this->response->addHeader('Content-Type', 'application/json');
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'seckill', roleModel::POWER_INSERT)) {
         $sname = $this->post->sname;
         $pid = filter::int($this->post->pid);
         $starttime = $this->post->starttime;
         $endtime = $this->post->endtime;
         $price = filter::number($this->post->price);
         $orderby = filter::int($this->post->orderby);
         $logo = $this->post->logo;
         if (!empty($pid)) {
             $productModel = $this->model('product');
             $product = $productModel->get($pid);
             if (empty($product) || !empty($product['activity'])) {
                 switch ($product['activity']) {
                     case 'sale':
                         $result = '限时优惠';
                         break;
                     case 'seckill':
                         $result = '秒杀';
                         break;
                     case 'fullcut':
                         $result = '满减';
                         break;
                 }
                 return json_encode(array('code' => 4, 'result' => '商品已经参加了' . $result . ',请先移除原活动在来添加'));
             }
             $seckillModel = $this->model('seckill');
             if ($seckillModel->create($sname, $pid, $starttime, $endtime, $price, $orderby, $logo)) {
                 $productModel->setActivity($pid, 'seckill');
                 return json_encode(array('code' => 1, 'result' => '推送成功'));
             } else {
                 return json_encode(array('code' => 2, 'result' => '推送失败'));
             }
         }
         return json_encode(array('code' => 0, 'result' => '参数错误'));
     }
     return json_encode(array('code' => 3, 'result' => '权限不足'));
 }