Beispiel #1
0
 /**
  * 向词库中添加词
  * @param $word  string 多个词以','分隔
  * @param $hot   int    0:否;1:是
  * @param $order int    排序
  */
 public static function add($word, $hot = 0, $order = 99)
 {
     $word = IFilter::act($word);
     $hot = intval($hot);
     $order = intval($order);
     if ($word != '') {
         $keywordObj = new IModel('keyword');
         $wordArray = explode(',', $word);
         $wordArray = array_unique($wordArray);
         //获取各个关键词的管理商品数量
         $resultCount = self::count($wordArray);
         foreach ($wordArray as $word) {
             if (IString::getStrLen($word) >= 15) {
                 continue;
             }
             $is_exists = $keywordObj->getObj('word = "' . $word . '"', 'hot');
             if (empty($is_exists)) {
                 $dataArray = array('hot' => $hot, 'word' => $word, 'goods_nums' => $resultCount[$word], 'order' => $order);
                 $keywordObj->setData($dataArray);
                 $keywordObj->add();
             } else {
                 $dataArray = array('hot' => $hot, 'order' => $order);
                 $keywordObj->setData($dataArray);
                 $keywordObj->update("word = '" . $word . "'");
             }
         }
         return array('flag' => true);
     }
     return array('flag' => false, 'data' => '请填写关键词');
 }
Beispiel #2
0
 /**
  * @brief 积分更新
  * @param int $user_id 用户ID
  * @param int $point   积分数(正,负)
  */
 private function editPoint($user_id, $point)
 {
     $memberObj = new IModel('member');
     $memberArray = array('point' => 'point + ' . $point);
     $memberObj->setData($memberArray);
     return $memberObj->update('user_id = ' . $user_id, 'point');
 }
Beispiel #3
0
 /**
  * @brief 商家登录动作
  */
 public function login()
 {
     $seller_name = IFilter::act(IReq::get('username'));
     $password = IReq::get('password');
     $message = '';
     if ($seller_name == '') {
         $message = '登录名不能为空';
     } else {
         if ($password == '') {
             $message = '密码不能为空';
         } else {
             $sellerObj = new IModel('seller');
             $sellerRow = $sellerObj->getObj('seller_name = "' . $seller_name . '" and is_del = 0 and is_lock = 0');
             if ($sellerRow && $sellerRow['password'] == md5($password)) {
                 $dataArray = array('login_time' => ITime::getDateTime());
                 $sellerObj->setData($dataArray);
                 $where = 'id = ' . $sellerRow["id"];
                 $sellerObj->update($where);
                 //存入私密数据
                 ISafe::set('seller_id', $sellerRow['id']);
                 ISafe::set('seller_name', $sellerRow['seller_name']);
                 ISafe::set('seller_pwd', $sellerRow['password']);
                 $this->redirect('/seller/index');
             } else {
                 $message = '用户名与密码不匹配';
             }
         }
     }
     if ($message != '') {
         $this->redirect('index', false);
         Util::showMessage($message);
     }
 }
Beispiel #4
0
 /**
  * @brief 保存品牌
  */
 function brand_save()
 {
     $brand_id = IFilter::act(IReq::get('brand_id'), 'int');
     $name = IFilter::act(IReq::get('name'));
     $sort = IFilter::act(IReq::get('sort'), 'int');
     $url = IFilter::act(IReq::get('url'));
     $description = IFilter::act(IReq::get('description'), 'text');
     $tb_brand = new IModel('brand');
     $brand = array('name' => $name, 'sort' => $sort, 'url' => $url, 'description' => $description);
     if (isset($_FILES['logo']['name']) && $_FILES['logo']['name'] != '') {
         $uploadObj = new PhotoUpload();
         $uploadObj->setIterance(false);
         $photoInfo = $uploadObj->run();
         if (isset($photoInfo['logo']['img']) && file_exists($photoInfo['logo']['img'])) {
             $brand['logo'] = $photoInfo['logo']['img'];
         }
     }
     $tb_brand->setData($brand);
     if ($brand_id) {
         $where = "id=" . $brand_id;
         $tb_brand->update($where);
     } else {
         $tb_brand->add();
     }
     $this->brand_list();
 }
Beispiel #5
0
 /**
  * @brief 回复建议
  */
 function suggestion_edit_act()
 {
     $id = intval(IReq::get('id', 'post'));
     $re_content = IFilter::act(IReq::get('re_content', 'post'), 'string');
     $tb = new IModel("suggestion");
     $data = array('admin_id' => $this->admin['admin_id'], 're_content' => $re_content, 're_time' => date('Y-m-d H:i:s'));
     $tb->setData($data);
     $tb->update("id={$id}");
     $this->redirect("/comment/suggestion_list");
 }
Beispiel #6
0
 /**
  * @brief 保存模板修改
  */
 function tpl_save()
 {
     $tid = intval(IReq::get('tpl_id', 'post'));
     if ($tid) {
         $title = IFilter::act(IReq::get('title'), 'string');
         $content = IFilter::act(IReq::get('content'), 'text');
         $tb_msg_template = new IModel('msg_template');
         $tb_msg_template->setData(array('title' => $title, 'content' => $content));
         $tb_msg_template->update('id=' . $tid);
     }
     $this->redirect('tpl_list');
 }
Beispiel #7
0
 function login_act()
 {
     $admin_name = IFilter::act(IReq::get('admin_name'));
     $password = IReq::get('password');
     $captcha = IReq::get('captcha', 'post');
     $message = '';
     if ($admin_name == '') {
         $message = '登录名不能为空';
     } else {
         if ($password == '') {
             $message = '密码不能为空';
         } else {
             if ($captcha != ISafe::get('Captcha')) {
                 $message = '验证码输入不正确';
             } else {
                 $adminObj = new IModel('admin');
                 $adminRow = $adminObj->getObj('admin_name = "' . $admin_name . '"');
                 if (!empty($adminRow) && $adminRow['password'] == md5($password) && $adminRow['is_del'] == 0) {
                     $dataArray = array('last_ip' => IClient::getIp(), 'last_time' => ITime::getDateTime());
                     $adminObj->setData($dataArray);
                     $where = 'id = ' . $adminRow["id"];
                     $adminObj->update($where);
                     //根据角色分配权限
                     if ($adminRow['role_id'] == 0) {
                         ISafe::set('admin_right', 'administrator');
                         ISafe::set('admin_role_name', '超级管理员');
                     } else {
                         $roleObj = new IModel('admin_role');
                         $where = 'id = ' . $adminRow["role_id"] . ' and is_del = 0';
                         $roleRow = $roleObj->getObj($where);
                         ISafe::set('admin_right', $roleRow['rights']);
                         ISafe::set('admin_role_name', $roleRow['name']);
                     }
                     ISafe::set('admin_id', $adminRow['id']);
                     ISafe::set('admin_name', $adminRow['admin_name']);
                     ISafe::set('admin_pwd', $adminRow['password']);
                     $this->redirect('/system/default');
                 } else {
                     $message = '用户名与密码不匹配';
                 }
             }
         }
     }
     if ($message != '') {
         $this->admin_name = $admin_name;
         $this->redirect('index', false);
         Util::showMessage($message);
     }
 }
Beispiel #8
0
 public static function ucenter_order()
 {
     $siteConfig = new Config('site_config');
     $order_cancel_time = $siteConfig->order_cancel_time !== "" ? intval($siteConfig->order_cancel_time) : 7;
     $order_finish_time = $siteConfig->order_finish_time !== "" ? intval($siteConfig->order_finish_time) : 20;
     $orderModel = new IModel('order');
     $orderCancelData = $order_cancel_time >= 0 ? $orderModel->query(" if_del = 0 and pay_type != 0 and status in(1) and datediff(NOW(),create_time) >= {$order_cancel_time} ", "id,order_no,4 as type_data") : array();
     $orderCreateData = $order_finish_time >= 0 ? $orderModel->query(" if_del = 0 and distribution_status = 1 and status in(1,2) and datediff(NOW(),send_time) >= {$order_finish_time} ", "id,order_no,5 as type_data") : array();
     $resultData = array_merge($orderCreateData, $orderCancelData);
     if ($resultData) {
         foreach ($resultData as $key => $val) {
             $type = $val['type_data'];
             $order_id = $val['id'];
             $order_no = $val['order_no'];
             //oerder表的对象
             $tb_order = new IModel('order');
             $tb_order->setData(array('status' => $type, 'completion_time' => ITime::getDateTime()));
             $tb_order->update('id=' . $order_id);
             //生成订单日志
             $tb_order_log = new IModel('order_log');
             //订单自动完成
             if ($type == '5') {
                 $action = '完成';
                 $note = '订单【' . $order_no . '】完成成功';
                 //完成订单并且进行支付
                 Order_Class::updateOrderStatus($order_no);
                 //增加用户评论商品机会
                 Order_Class::addGoodsCommentChange($order_id);
                 $logObj = new log('db');
                 $logObj->write('operation', array("系统自动", "订单更新为完成", '订单号:' . $order_no));
             } else {
                 $action = '作废';
                 $note = '订单【' . $order_no . '】作废成功';
                 //订单重置取消
                 Order_class::resetOrderProp($order_id);
                 $logObj = new log('db');
                 $logObj->write('operation', array("系统自动", "订单更新为作废", '订单号:' . $order_no));
             }
             $tb_order_log->setData(array('order_id' => $order_id, 'user' => "系统自动", 'action' => $action, 'result' => '成功', 'note' => $note, 'addtime' => ITime::getDateTime()));
             $tb_order_log->add();
         }
     }
 }
Beispiel #9
0
 /**
  * 写入日志并且更新账户余额
  * @param array $config config数据类型
  * @return string|bool
  */
 public function write($config)
 {
     if (isset($config['user_id'])) {
         $this->setUser($config['user_id']);
     } else {
         throw new IException("用户信息不存在");
     }
     isset($config['seller_id']) ? $this->setSeller($config['seller_id']) : "";
     isset($config['admin_id']) ? $this->setAdmin($config['admin_id']) : "";
     isset($config['event']) ? $this->setEvent($config['event']) : "";
     if (isset($config['num']) && is_numeric($config['num'])) {
         $this->amount = abs(round($config['num'], 2));
         //金额正负值处理
         if (in_array($this->allow_event[$this->event], array(2, 3))) {
             $this->amount = '-' . abs($this->amount);
         }
     } else {
         throw new IException("金额必须大于0元");
     }
     $this->config = $config;
     $this->noteData = isset($config['note']) ? $config['note'] : $this->note();
     //写入数据库
     $finnalAmount = $this->user['balance'] + $this->amount;
     if ($finnalAmount < 0) {
         throw new IException("用户余额不足");
     }
     $memberDB = new IModel('member');
     $memberDB->setData(array("balance" => $finnalAmount));
     $memberDB->update("user_id = " . $this->user['id']);
     $tb_account_log = new IModel("account_log");
     $insertData = array('admin_id' => $this->admin ? $this->admin['id'] : 0, 'user_id' => $this->user['id'], 'event' => $this->allow_event[$this->event], 'note' => $this->noteData, 'amount' => $this->amount, 'amount_log' => $finnalAmount, 'type' => $this->amount >= 0 ? 0 : 1, 'time' => ITime::getDateTime());
     $tb_account_log->setData($insertData);
     $result = $tb_account_log->add();
     //后台管理员操作记录
     if ($insertData['admin_id']) {
         $logObj = new log('db');
         $logObj->write('operation', array("管理员:" . $this->admin['admin_name'], "对账户金额进行了修改", $insertData['note']));
     }
     return $result;
 }
Beispiel #10
0
 /**
  * @brief 发送到货通知邮件
  */
 function notify_send()
 {
     $smtp = new SendMail();
     $error = $smtp->getError();
     if ($error) {
         $return = array('isError' => true, 'message' => $error);
         echo JSON::encode($return);
         exit;
     }
     $notify_ids = IFilter::act(IReq::get('notifyid'));
     $message = '';
     if ($notify_ids && is_array($notify_ids)) {
         $ids = join(',', $notify_ids);
         $query = new IQuery("notify_registry as notify");
         $query->join = "right join goods as goods on notify.goods_id=goods.id left join user as u on notify.user_id = u.id";
         $query->fields = "notify.*,u.username,goods.name as goods_name,goods.store_nums";
         $query->where = "notify.id in(" . $ids . ")";
         $items = $query->find();
         //库存大于0,且处于未发送状态的 发送通知
         $succeed = 0;
         $failed = 0;
         $tb_notify_registry = new IModel('notify_registry');
         foreach ($items as $value) {
             $body = mailTemplate::notify(array('{goodsName}' => $value['goods_name'], '{url}' => IUrl::getHost() . IUrl::creatUrl('/site/products/id/' . $value['goods_id'])));
             $status = $smtp->send($value['email'], "到货通知", $body);
             if ($status) {
                 //发送成功
                 $succeed++;
                 $data = array('notify_time' => ITime::getDateTime(), 'notify_status' => '1');
                 $tb_notify_registry->setData($data);
                 $tb_notify_registry->update('id=' . $value['id']);
             } else {
                 //发送失败
                 $failed++;
             }
         }
     }
     $return = array('isError' => false, 'count' => count($items), 'succeed' => $succeed, 'failed' => $failed);
     echo JSON::encode($return);
 }
Beispiel #11
0
 function keyword_order()
 {
     $word = IFilter::act(IReq::get('id'));
     $order = IReq::get('order') ? intval(IReq::get('order')) : 99;
     $keywordObj = new IModel('keyword');
     $dataArray = array('order' => $order);
     $keywordObj->setData($dataArray);
     $is_success = $keywordObj->update('word = "' . $word . '"');
     if ($is_success === false) {
         $result = array('isError' => true, 'message' => '更新排序失败');
     } else {
         $result = array('isError' => false);
     }
     echo JSON::encode($result);
 }
Beispiel #12
0
 function refundment_update()
 {
     $id = IFilter::act(IReq::get('id'), 'int');
     $pay_status = IFilter::act(IReq::get('pay_status'), 'int');
     $dispose_idea = IFilter::act(IReq::get('dispose_idea'));
     //商户处理退款
     if ($id && Order_Class::isSellerRefund($id, $this->seller['seller_id']) == 2) {
         $tb_refundment_doc = new IModel('refundment_doc');
         $updateData = array('dispose_time' => ITime::getDateTime(), 'dispose_idea' => $dispose_idea, 'pay_status' => $pay_status);
         $tb_refundment_doc->setData($updateData);
         $tb_refundment_doc->update('id = ' . $id);
         if ($pay_status == 2) {
             $result = Order_Class::refund($id, $this->seller['seller_id'], 'seller');
             if (!$result) {
                 die('退款失败');
             }
         }
     }
     $this->redirect('refundment_list');
 }
Beispiel #13
0
 public static function mod_cat_position($id, $position, $value)
 {
     $id = intval($id);
     $value = intval($value) == 1 ? 1 : 0;
     if ($position != 'left' && $position != 'foot') {
         return array('flag' => false, 'data' => '错误的位置');
     }
     $tb_help_category = new IModel("help_category");
     $tb_help_category->setData(array("position_{$position}" => $value));
     $tb_help_category->update("id={$id}");
     return array('flag' => true);
 }
Beispiel #14
0
 /**
  * @brief 登录后的处理
  * @param array $userRow 用户数组信息
  */
 public static function loginAfter($userRow)
 {
     //用户私密数据
     ISafe::set('user_id', $userRow['id']);
     ISafe::set('username', $userRow['username']);
     ISafe::set('head_ico', $userRow['head_ico']);
     ISafe::set('user_pwd', $userRow['password']);
     ISafe::set('last_login', isset($userRow['last_login']) ? $userRow['last_login'] : '');
     //更新最后一次登录时间
     $memberObj = new IModel('member');
     $dataArray = array('last_login' => ITime::getDateTime());
     $memberObj->setData($dataArray);
     $where = 'user_id = ' . $userRow["id"];
     $memberObj->update($where);
     $memberRow = $memberObj->getObj($where, 'exp');
     //根据经验值分会员组
     $groupObj = new IModel('user_group');
     $groupRow = $groupObj->getObj($memberRow['exp'] . ' between minexp and maxexp and minexp > 0 and maxexp > 0', 'id', 'discount', 'desc');
     if (!empty($groupRow)) {
         $dataArray = array('group_id' => $groupRow['id']);
         $memberObj->setData($dataArray);
         $memberObj->update('user_id = ' . $userRow["id"]);
     }
 }
 public function expresswaybill_edit_act()
 {
     $id = intval(IReq::get('id'));
     $printExpress = IReq::get('printExpress');
     $name = IFilter::act(IReq::get('express_name'));
     $width = intval(IReq::get('width'));
     $height = intval(IReq::get('height'));
     $background = IFilter::act(IReq::get('printBackground'));
     $background = ltrim($background, IUrl::creatUrl(''));
     if (!$printExpress) {
         $printExpress = array();
     }
     if (!$name) {
         die('快递单的名称不能为空');
     }
     $expressObj = new IModel('expresswaybill');
     $data = array('config' => serialize($printExpress), 'name' => $name, 'width' => $width, 'height' => $height, 'background' => $background);
     $expressObj->setData($data);
     //修改模式
     if ($id) {
         $is_result = $expressObj->update('id = ' . $id);
     } else {
         $is_result = $expressObj->add();
     }
     echo $is_result === false ? '操作失败' : 'success';
 }
Beispiel #16
0
 public function update_print_status()
 {
     $order_id = IFilter::act(IReq::get('order_id'), 'int');
     $order_id = is_array($order_id) ? join(',', $order_id) : $order_id;
     $print_type = IFilter::act(IReq::get('print_type'));
     $orderObj = new IModel('order');
     $orderList = $orderObj->query('id in (' . $order_id . ')', 'if_print');
     foreach ($orderList as $orderRow) {
         if (isset($orderRow['if_print']) && strpos($orderRow['if_print'], $print_type) === false) {
             if ($orderRow['if_print'] == '') {
                 $if_print = $print_type;
             } else {
                 $if_print = $orderRow['if_print'] . ',' . $print_type;
             }
             $orderObj->setData(array('if_print' => $if_print));
             $orderObj->update("id = " . $orderRow['id']);
         }
     }
 }
Beispiel #17
0
 static function get_order_pri_num_del($ogid)
 {
     $total = 0;
     $goods_id = '';
     $p_id = '';
     $number = '';
     //先根据ogid查询出order_goods单价和数量,然后从order表总价格中删除
     $query = new IQuery('order_goods');
     $query->where = 'id = ' . $ogid;
     $order_goods_info = $query->find();
     if (count($order_goods_info) > 0) {
         $order_id = $order_goods_info[0]['order_id'];
         $goods_price = $order_goods_info[0]['goods_price'];
         $real_price = $order_goods_info[0]['real_price'];
         $goods_nums = $order_goods_info[0]['goods_nums'];
         $number = $goods_nums;
         $goods_id = $order_goods_info[0]['goods_id'];
         $p_id = $order_goods_info[0]['product_id'];
         $tb_order = new IModel('order');
         $tb_order->setData(array('payable_amount' => 'payable_amount-' . $goods_price * $goods_nums, 'real_amount' => 'real_amount-' . $real_price * $goods_nums, 'order_amount' => 'order_amount-' . $real_price * $goods_nums));
         $arr = array('payable_amount', 'real_amount', 'order_amount');
         $tb_order->update('id=' . $order_id, $arr);
     }
     $islog = 0;
     $tb_order_goods = new IModel('order_goods');
     if ($tb_order_goods->del('id=' . $ogid)) {
         $islog = 1;
     }
     //修改goods表中数量,获得goods表的对象
     $tb_goods = new IModel('goods');
     $tb_goods->setData(array('store_nums' => 'store_nums+' . $number));
     $grr = array('store_nums');
     $tb_goods->update('id=' . $goods_id, $grr);
     //判断p_id是否有值如果有则修改products中的数量
     if ($p_id != 0) {
         $tb_products = new IModel('products');
         $tb_products->setData(array('store_nums' => 'store_nums+' . $number));
         $prr = array('store_nums');
         $tb_products->update('id=' . $p_id, $prr);
     }
     return $islog;
 }
Beispiel #18
0
 /**
  * @brief 修改商品数据
  * @param int $id 商品ID
  * @param array $paramData 商品所需数据
  */
 public function update($id, $paramData)
 {
     $postData = array();
     $nowDataTime = ITime::getDateTime();
     foreach ($paramData as $key => $val) {
         $postData[$key] = $val;
         //数据过滤分组
         if (strpos($key, 'attr_id_') !== false) {
             $goodsAttrData[ltrim($key, 'attr_id_')] = IFilter::act($val);
         } else {
             if ($key == 'content') {
                 $goodsUpdateData['content'] = IFilter::addSlash($val);
             } else {
                 if ($key[0] != '_') {
                     $goodsUpdateData[$key] = IFilter::act($val, 'text');
                 }
             }
         }
     }
     //商家发布商品默认设置
     if ($this->seller_id) {
         $goodsUpdateData['seller_id'] = $this->seller_id;
         $goodsUpdateData['is_del'] = $goodsUpdateData['is_del'] == 2 ? 2 : 3;
         //如果商户是VIP则无需审核商品
         if ($goodsUpdateData['is_del'] == 3) {
             $sellerDB = new IModel('seller');
             $sellerRow = $sellerDB->getObj('id = ' . $this->seller_id);
             if ($sellerRow['is_vip'] == 1) {
                 $goodsUpdateData['is_del'] = 0;
             }
         }
     }
     //上架或者下架处理
     if (isset($goodsUpdateData['is_del'])) {
         //上架
         if ($goodsUpdateData['is_del'] == 0) {
             $goodsUpdateData['up_time'] = $nowDataTime;
             $goodsUpdateData['down_time'] = null;
         } else {
             if ($goodsUpdateData['is_del'] == 2) {
                 $goodsUpdateData['up_time'] = null;
                 $goodsUpdateData['down_time'] = $nowDataTime;
             } else {
                 $goodsUpdateData['up_time'] = null;
                 $goodsUpdateData['down_time'] = null;
             }
         }
     }
     //是否存在货品
     $goodsUpdateData['spec_array'] = '';
     if (isset($postData['_spec_array'])) {
         //生成goods中的spec_array字段数据
         $goods_spec_array = array();
         foreach ($postData['_spec_array'] as $key => $val) {
             foreach ($val as $v) {
                 $tempSpec = JSON::decode($v);
                 if (!isset($goods_spec_array[$tempSpec['id']])) {
                     $goods_spec_array[$tempSpec['id']] = array('id' => $tempSpec['id'], 'name' => $tempSpec['name'], 'type' => $tempSpec['type'], 'value' => array());
                 }
                 $goods_spec_array[$tempSpec['id']]['value'][] = $tempSpec['value'];
             }
         }
         foreach ($goods_spec_array as $key => $val) {
             $val['value'] = array_unique($val['value']);
             $goods_spec_array[$key]['value'] = join(',', $val['value']);
         }
         $goodsUpdateData['spec_array'] = JSON::encode($goods_spec_array);
     }
     $goodsUpdateData['goods_no'] = isset($postData['_goods_no']) ? current($postData['_goods_no']) : '';
     $goodsUpdateData['store_nums'] = array_sum($postData['_store_nums']);
     $goodsUpdateData['market_price'] = isset($postData['_market_price']) ? current($postData['_market_price']) : 0;
     $goodsUpdateData['sell_price'] = isset($postData['_sell_price']) ? current($postData['_sell_price']) : 0;
     $goodsUpdateData['cost_price'] = isset($postData['_cost_price']) ? current($postData['_cost_price']) : 0;
     $goodsUpdateData['weight'] = isset($postData['_weight']) ? current($postData['_weight']) : 0;
     //处理商品
     $goodsDB = new IModel('goods');
     if ($id) {
         $goodsDB->setData($goodsUpdateData);
         $where = " id = {$id} ";
         if ($this->seller_id) {
             $where .= " and seller_id = " . $this->seller_id;
         }
         if ($goodsDB->update($where) === false) {
             die("更新商品错误");
         }
     } else {
         $goodsUpdateData['create_time'] = $nowDataTime;
         $goodsDB->setData($goodsUpdateData);
         $id = $goodsDB->add();
     }
     //处理商品属性
     $goodsAttrDB = new IModel('goods_attribute');
     $goodsAttrDB->del('goods_id = ' . $id);
     if (isset($goodsAttrData) && $goodsAttrData) {
         foreach ($goodsAttrData as $key => $val) {
             $attrData = array('goods_id' => $id, 'model_id' => $goodsUpdateData['model_id'], 'attribute_id' => $key, 'attribute_value' => is_array($val) ? join(',', $val) : $val);
             $goodsAttrDB->setData($attrData);
             $goodsAttrDB->add();
         }
     }
     //是否存在货品
     $productsDB = new IModel('products');
     $productsDB->del('goods_id = ' . $id);
     if (isset($postData['_spec_array'])) {
         $productIdArray = array();
         //创建货品信息
         foreach ($postData['_goods_no'] as $key => $rs) {
             $productsData = array('goods_id' => $id, 'products_no' => $postData['_goods_no'][$key], 'store_nums' => $postData['_store_nums'][$key], 'market_price' => $postData['_market_price'][$key], 'sell_price' => $postData['_sell_price'][$key], 'cost_price' => $postData['_cost_price'][$key], 'weight' => $postData['_weight'][$key], 'spec_array' => "[" . join(',', $postData['_spec_array'][$key]) . "]");
             $productsDB->setData($productsData);
             $productIdArray[$key] = $productsDB->add();
         }
     }
     //处理商品分类
     $categoryDB = new IModel('category_extend');
     $categoryDB->del('goods_id = ' . $id);
     if (isset($postData['_goods_category']) && $postData['_goods_category']) {
         foreach ($postData['_goods_category'] as $item) {
             $categoryDB->setData(array('goods_id' => $id, 'category_id' => $item));
             $categoryDB->add();
         }
     }
     //处理商品促销
     $commendDB = new IModel('commend_goods');
     $commendDB->del('goods_id = ' . $id);
     if (isset($postData['_goods_commend']) && $postData['_goods_commend']) {
         foreach ($postData['_goods_commend'] as $item) {
             $commendDB->setData(array('goods_id' => $id, 'commend_id' => $item));
             $commendDB->add();
         }
     }
     //处理商品关键词
     keywords::add($goodsUpdateData['search_words']);
     //处理商品图片
     $photoRelationDB = new IModel('goods_photo_relation');
     $photoRelationDB->del('goods_id = ' . $id);
     if (isset($postData['_imgList']) && $postData['_imgList']) {
         $postData['_imgList'] = str_replace(',', '","', trim($postData['_imgList'], ','));
         $photoDB = new IModel('goods_photo');
         $photoData = $photoDB->query('img in ("' . $postData['_imgList'] . '")', 'id');
         if ($photoData) {
             foreach ($photoData as $item) {
                 $photoRelationDB->setData(array('goods_id' => $id, 'photo_id' => $item['id']));
                 $photoRelationDB->add();
             }
         }
     }
     //处理会员组的价格
     $groupPriceDB = new IModel('group_price');
     $groupPriceDB->del('goods_id = ' . $id);
     if (isset($productIdArray) && $productIdArray) {
         foreach ($productIdArray as $index => $value) {
             if (isset($postData['_groupPrice'][$index]) && $postData['_groupPrice'][$index]) {
                 $temp = JSON::decode($postData['_groupPrice'][$index]);
                 foreach ($temp as $k => $v) {
                     $groupPriceDB->setData(array('goods_id' => $id, 'product_id' => $value, 'group_id' => $k, 'price' => $v));
                     $groupPriceDB->add();
                 }
             }
         }
     } else {
         if (isset($postData['_groupPrice'][0]) && $postData['_groupPrice'][0]) {
             $temp = JSON::decode($postData['_groupPrice'][0]);
             foreach ($temp as $k => $v) {
                 $groupPriceDB->setData(array('goods_id' => $id, 'group_id' => $k, 'price' => $v));
                 $groupPriceDB->add();
             }
         }
     }
     return true;
 }
Beispiel #19
0
 /**
  * @brief 品牌分类排序
  */
 function brand_sort()
 {
     $brand_id = IFilter::act(IReq::get('id'));
     $sort = IFilter::act(IReq::get('sort'));
     $flag = 0;
     if ($brand_id) {
         $tb_brand = new IModel('brand');
         $brand_info = $tb_brand->getObj('id=' . $brand_id);
         if (count($brand_info) > 0) {
             if ($brand_info['sort'] != $sort) {
                 $tb_brand->setData(array('sort' => $sort));
                 if ($tb_brand->update('id=' . $brand_id)) {
                     $flag = 1;
                 }
             }
         }
     }
     echo $flag;
 }
Beispiel #20
0
 /**
  * 余额付款
  * T:支付失败;
  * F:支付成功;
  */
 function payment_balance()
 {
     $urlStr = '';
     $user_id = intval($this->user['user_id']);
     $return['attach'] = IReq::get('attach');
     $return['total_fee'] = IReq::get('total_fee');
     $return['order_no'] = IReq::get('order_no');
     $return['return_url'] = IReq::get('return_url');
     $sign = IReq::get('sign');
     if (stripos($return['order_no'], 'recharge_') !== false) {
         IError::show(403, '余额支付方式不能用于在线充值');
         exit;
     }
     if (floatval($return['total_fee']) <= 0 || $return['order_no'] == '' || $return['return_url'] == '') {
         IError::show(403, '支付参数不正确');
     } else {
         $paymentDB = new IModel('payment');
         $paymentRow = $paymentDB->getObj('class_name = "balance" ');
         $pkey = Payment::getConfigParam($paymentRow['id'], 'M_PartnerKey');
         //md5校验
         ksort($return);
         foreach ($return as $key => $val) {
             $urlStr .= $key . '=' . urlencode($val) . '&';
         }
         $urlStr .= $user_id . $pkey;
         if ($sign != md5($urlStr)) {
             IError::show(403, '数据校验不正确');
         } else {
             $memberObj = new IModel('member');
             $memberRow = $memberObj->getObj('user_id = ' . $user_id);
             if (empty($memberRow)) {
                 IError::show(403, '用户信息不存在');
                 exit;
             } else {
                 if ($memberRow['balance'] < $return['total_fee']) {
                     IError::show(403, '账户余额不足');
                     exit;
                 } else {
                     $orderObj = new IModel('order');
                     $orderRow = $orderObj->getObj('order_no  = "' . IFilter::act($return['order_no']) . '" and pay_status = 0 and user_id = ' . $user_id);
                     if (empty($orderRow)) {
                         IError::show(403, '订单已经被处理过,请查看订单状态');
                         exit;
                     }
                     $dataArray = array('balance' => 'balance - ' . IFilter::act($return['total_fee']));
                     $memberObj->setData($dataArray);
                     $is_success = $memberObj->update('user_id = ' . $user_id, 'balance');
                     if ($is_success) {
                         $return['is_success'] = 'T';
                     } else {
                         $return['is_success'] = 'F';
                     }
                     ksort($return);
                     //返还的URL地址
                     $responseUrl = '';
                     foreach ($return as $key => $val) {
                         $responseUrl .= $key . '=' . urlencode($val) . '&';
                     }
                     $nextUrl = urldecode($return['return_url']);
                     if (stripos($nextUrl, '?') === false) {
                         $return_url = $nextUrl . '?' . $responseUrl;
                     } else {
                         $return_url = $nextUrl . '&' . $responseUrl;
                     }
                     //计算要发送的md5校验
                     $urlStrMD5 = md5($responseUrl . $user_id . $pkey);
                     //拼接进返还的URL中
                     $return_url .= 'sign=' . $urlStrMD5;
                     header('location:' . $return_url);
                 }
             }
         }
     }
 }
Beispiel #21
0
 /**
  * @brief 从回收站还原会员
  */
 function member_restore()
 {
     $user_ids = IReq::get('check');
     $user_ids = is_array($user_ids) ? $user_ids : array($user_ids);
     if ($user_ids) {
         $user_ids = IFilter::act($user_ids, 'int');
         $ids = implode(',', $user_ids);
         if ($ids) {
             $tb_member = new IModel('member');
             $tb_member->setData(array('status' => '1'));
             $where = "user_id in (" . $ids . ")";
             $tb_member->update($where);
         }
     }
     $this->redirect('recycling');
 }
Beispiel #22
0
 /**
  * @brief 回复咨询信息
  */
 function refer_reply()
 {
     $rid = intval(IReq::get('refer_id', 'post'));
     $content = IReq::get('content');
     if ($rid && $content) {
         $content = IFilter::string($content, true);
         $tb_refer = new IModel('refer');
         $admin_id = $this->admin['admin_id'];
         //管理员id
         $data = array('answer' => $content, 'reply_time' => date('Y-m-d H:i:s'), 'admin_id' => $admin_id, 'status' => 1);
         $tb_refer->setData($data);
         $tb_refer->update("id=" . $rid);
     }
     $this->refer_list();
 }
Beispiel #23
0
 function withdraw_status()
 {
     $id = IFilter::act(IReq::get('id'), 'int');
     $re_note = IFilter::act(IReq::get('re_note'), 'string');
     if ($id) {
         $withdrawObj = new IModel('withdraw');
         $dataArray = array('re_note' => $re_note);
         if (IReq::get('status') !== NULL) {
             $dataArray['status'] = IFilter::act(IReq::get('status'), 'int');
         }
         $withdrawObj->setData($dataArray);
         $where = "`id`= {$id} AND `status` = 0";
         $re = $withdrawObj->update($where);
         $this->withdraw_detail(true);
         if ($re != 0) {
             $logObj = new log('db');
             $logObj->write('operation', array("管理员:" . $this->admin['admin_name'], "修改了提现申请", "ID值为:" . $id));
         }
         Util::showMessage("更新成功");
     } else {
         $this->redirect('withdraw_list');
     }
 }
Beispiel #24
0
 /**
  * 订单商品数量更新操作[公共]
  * @param $order_id 订单ID
  * @param $type 增加或者减少 add 或者 reduce
  */
 public static function updateStore($order_id, $type = 'add')
 {
     $newStoreNums = 0;
     $updateGoodsId = array();
     $orderGoodsObj = new IModel('order_goods');
     $goodsObj = new IModel('goods');
     $productObj = new IModel('products');
     $goodsList = $orderGoodsObj->query('order_id = ' . $order_id, 'goods_id,product_id,goods_nums');
     foreach ($goodsList as $key => $val) {
         //货品库存更新
         if ($val['product_id'] != 0) {
             $productsRow = $productObj->getObj('id = ' . $val['product_id'], 'store_nums');
             $localStoreNums = $productsRow['store_nums'];
             //同步更新所属商品的库存量
             if (in_array($val['goods_id'], $updateGoodsId) == false) {
                 $updateGoodsId[] = $val['goods_id'];
             }
             $newStoreNums = $type == 'add' ? $localStoreNums + $val['goods_nums'] : $localStoreNums - $val['goods_nums'];
             $newStoreNums = $newStoreNums > 0 ? $newStoreNums : 0;
             $productObj->setData(array('store_nums' => $newStoreNums));
             $productObj->update('id = ' . $val['product_id'], 'store_nums');
         } else {
             $goodsRow = $goodsObj->getObj('id = ' . $val['goods_id'], 'store_nums');
             $localStoreNums = $goodsRow['store_nums'];
             $newStoreNums = $type == 'add' ? $localStoreNums + $val['goods_nums'] : $localStoreNums - $val['goods_nums'];
             $newStoreNums = $newStoreNums > 0 ? $newStoreNums : 0;
             $goodsObj->setData(array('store_nums' => $newStoreNums));
             $goodsObj->update('id = ' . $val['goods_id'], 'store_nums');
         }
         //更新销售量sale字段,库存减少销售量增加,两者成反比
         $saleData = $type == 'add' ? -$val['goods_nums'] : $val['goods_nums'];
         $goodsObj->setData(array('sale' => 'sale + ' . $saleData));
         $goodsObj->update('id = ' . $val['goods_id'], 'sale');
     }
     //更新统计goods的库存
     if ($updateGoodsId) {
         foreach ($updateGoodsId as $val) {
             $totalRow = $productObj->getObj('goods_id = ' . $val, 'SUM(store_nums) as store');
             $goodsObj->setData(array('store_nums' => $totalRow['store']));
             $goodsObj->update('id = ' . $val);
         }
     }
 }
Beispiel #25
0
 /**
  * @brief 记录支付平台的交易号
  * @param $orderNo string 订单编号
  * @param $tradeNo string 交易流水号
  * @return boolean
  */
 protected function recordTradeNo($orderNo, $tradeNo)
 {
     $orderDB = new IModel('order');
     $orderDB->setData(array('trade_no' => $tradeNo));
     return $orderDB->update('order_no = "' . $orderNo . '"');
 }
Beispiel #26
0
 /**
  * @brief 验证邮箱
  */
 public function check_mail()
 {
     $code = IReq::get("code");
     list($email, $user_id) = explode('|', base64_decode($code));
     $email = IFilter::act($email);
     $user_id = IFilter::act($user_id, 'int');
     $userDB = new IModel("user");
     $userRow = $userDB->getObj(" email = '{$email}' and id = " . $user_id);
     if ($userRow) {
         CheckRights::loginAfter($userRow);
         $memberObj = new IModel("member");
         $memberObj->setData(array("status" => 1));
         $memberObj->update("user_id = " . $user_id);
         $message = "恭喜,您的邮箱激活成功!";
     } else {
         $message = "验证信息有误,请核实!";
     }
     $this->redirect('/site/success?message=' . urlencode($message));
 }
Beispiel #27
0
 /**
  * @brief 商品属性添加/修改
  * @param array $attribute 表字段 数组格式,如Array ([name] 		=> Array ( [0] => '' )
  *													[show_type] => Array ( [0] => '' )
  *													[value] 	=> Array ( [0] => '' )
  *													[is_seach] 	=> Array ( [0] => 1 ))
  * @param int $model_id 模型编号
  */
 public function attribute_update($attribute, $model_id)
 {
     //初始化attribute商品模型属性表类对象
     $attributeObj = new IModel('attribute');
     $len = count($attribute['name']);
     $ids = "";
     for ($i = 0; $i < $len; $i++) {
         if (isset($attribute['name'][$i]) && isset($attribute['value'][$i])) {
             $options = str_replace(',', ',', $attribute['value'][$i]);
             $type = isset($attribute['is_search'][$i]) ? $attribute['is_search'][$i] : 0;
             //设置商品模型扩展属性 字段赋值
             $filedData = array("model_id" => intval($model_id), "type" => IFilter::act($attribute['show_type'][$i]), "name" => $attribute['name'][$i], "value" => rtrim($options, ','), "search" => IFilter::act($type));
             $attributeObj->setData($filedData);
             $id = intval($attribute['id'][$i]);
             if ($id) {
                 //更新商品模型扩展属性
                 $attributeObj->update("id = " . $id);
             } else {
                 //新增商品模型扩展属性
                 $id = $attributeObj->add();
             }
             $ids .= $id . ',';
         }
     }
     if ($ids) {
         $ids = trim($ids, ',');
         //删除商品模型扩展属性
         $where = "model_id = {$model_id}  and id not in (" . $ids . ") ";
         $attributeObj->del($where);
     }
 }
Beispiel #28
0
 public function oauth_edit_act()
 {
     $id = IFilter::act(IReq::get('id'));
     if ($id == 0) {
         $this->redirect('oauth_list', false);
         Util::showMessage('请选择要修改的登录平台');
         exit;
     }
     $oauthDBObj = new IModel('oauth');
     $oauthRow = $oauthDBObj->getObj('id = ' . $id);
     if (empty($oauthRow)) {
         $this->redirect('oauth_list', false);
         Util::showMessage('请选择要修改的登录平台');
         exit;
     }
     $dataArray = array('name' => IFilter::act(IReq::get('name')), 'is_close' => IFilter::act(IReq::get('is_close')), 'description' => IFilter::act(IReq::get('description')), 'config' => array());
     //获取字段数据
     $oauthObj = new Oauth($id);
     $oauthFields = $oauthObj->getFields();
     if (!empty($oauthFields)) {
         $parmsArray = array_keys($oauthFields);
         foreach ($parmsArray as $val) {
             $dataArray['config'][$val] = IFilter::act(IReq::get($val));
         }
     }
     $dataArray['config'] = serialize($dataArray['config']);
     $oauthDBObj->setData($dataArray);
     $oauthDBObj->update('id = ' . $id);
     $this->redirect('oauth_list');
 }
Beispiel #29
0
 function add_download_ticket()
 {
     $isError = true;
     $ticket_num = IFilter::act(IReq::get('ticket_num'));
     $ticket_pwd = IFilter::act(IReq::get('ticket_pwd'));
     $propObj = new IModel('prop');
     $propRow = $propObj->getObj('card_name = "' . $ticket_num . '" and card_pwd = "' . $ticket_pwd . '" and type = 0 and is_userd = 0 and is_send = 1 and is_close = 0 and NOW() between start_time and end_time');
     if (empty($propRow)) {
         $message = '代金券不可用,请确认代金券的卡号密码并且此代金券从未被使用过';
     } else {
         //登录用户
         if ($this->user['user_id']) {
             $memberObj = new IModel('member');
             $memberRow = $memberObj->getObj('user_id = ' . $this->user['user_id'], 'prop');
             if (stripos($memberRow['prop'], ',' . $propRow['id'] . ',') !== false) {
                 $message = '代金券已经存在,不能重复添加';
             } else {
                 $isError = false;
                 $message = '添加成功';
                 if ($memberRow['prop'] == '') {
                     $propUpdate = ',' . $propRow['id'] . ',';
                 } else {
                     $propUpdate = $memberRow['prop'] . $propRow['id'] . ',';
                 }
                 $dataArray = array('prop' => $propUpdate);
                 $memberObj->setData($dataArray);
                 $memberObj->update('user_id = ' . $this->user['user_id']);
             }
         } else {
             $isError = false;
             $message = '添加成功';
             ISafe::set("ticket_" . $propRow['id'], $propRow['id']);
         }
     }
     $result = array('isError' => $isError, 'data' => $propRow, 'message' => $message);
     echo JSON::encode($result);
 }
Beispiel #30
0
 public function goods_share()
 {
     $idArray = explode(',', IReq::get('id'));
     $id = IFilter::act($idArray, 'int');
     $goodsDB = new IModel('goods');
     $goodsData = $goodsDB->query('id in (' . join(',', $id) . ')');
     foreach ($goodsData as $key => $val) {
         $is_share = $val['is_share'] == 1 ? 0 : 1;
         $goodsDB->setData(array('is_share' => $is_share));
         $goodsDB->update('id = ' . $val['id'] . ' and seller_id = 0');
     }
 }