function send() { $uid = $this->_post('uid'); $content = parent::_postContent('content'); if (!$uid) { $this->JsonReturn('参数丢失', array('code' => '', 'msg' => ''), 0); } if (!$content) { $this->JsonReturn('回复内容不能为空', array('code' => '', 'msg' => ''), 0); } $touser = D('member')->getOpenidByUids($uid); if (!$touser) { $this->JsonReturn('用户不存在', array('code' => '', 'msg' => ''), 0); } $sendInfo = array('touser' => $touser, 'msgtype' => 'text', 'text' => array('content' => $content)); // z($sendInfo); T('weixin/weixin.api'); $weixinMsgApi = new weixinMsgApi(); if ($weixinMsgApi->sendCustomMessage($sendInfo)) { return $this->JsonReturn('回复成功', null, 1); } else { return $this->JsonReturn('回复失败', array('code' => $weixinMsgApi->errCode, 'msg' => $weixinMsgApi->errMsg), 0); } }
public function save() { parent::_checkLogin(); parent::_authUser(array(1, 2, 5, 7, 8)); $id = $this->_postid('id', 0); if (!$id) { $this->JsonReturn('参数丢失'); } $rs = M('ste_goods')->where(array('gid' => $id))->find(); if (!$rs) { showError('商品不存在'); } if (!parent::_checkUser($rs['user_id'], $rs['shop_id']) && (parent::_checkIsPresident() && $rs['service_id'] != steadmin::$adminInfo['service_id'])) { showError('没有编辑权限'); } $objData = array(); $noField = array('goods_sn', 'user_id', 'sale_counts', 'hits_counts', 'love_counts', 'info_time', 'shop_id', 'status', 'service_id'); //获取字段内容 $fieldList = M('ste_goods')->getTableFields($noField); foreach ($fieldList['fields'] as $key => $val) { $objData[$key] = $val['type'] == 'int' ? $this->_postid($key, $val['value']) : $this->_post($key, $val['value']); } $objData['goods_tips'] = $this->_post('goods_tips'); $objData['start_times'] = $this->_post('start_times'); $objData['end_times'] = $this->_post('end_times'); $goodsParameter = $this->_post('goods_parameter'); $objData['goods_desc'] = parent::_postContent('goods_desc'); if ($objData['goods_tips']) { $objData['goods_tips'] = ',' . implode(',', $objData['goods_tips']) . ','; } $objData['goods_parameter'] = ''; if ($goodsParameter) { $count = count($goodsParameter['n']); for ($i = 0; $i < $count; $i += 1) { isHave($goodsParameter['v'][$i]) && ($objData['goods_parameter'][] = array($goodsParameter['n'][$i], $goodsParameter['v'][$i])); } } if ($objData['goods_parameter']) { $objData['goods_parameter'] = json_encode($objData['goods_parameter']); } if (!$objData['is_realtime']) { $objData['booked_time'] = 0; } //内容规则检查 T('content/validate'); $validate = array(array('goods_name', 'range_length', '商品名称不符合要求', 2, 80), array('goods_pic', 'required', '商品小图不能为空'), array('price', 'currency', '商品价格不正确'), array('px', 'int', '排序值必须为正整数'), array('start_times', 'required', '上架时间不能为空'), array('end_times', 'required', '下架时间不能为空')); if ($objData['original_price']) { $validate[] = array('original_price', 'currency', '商品原始价格不正确'); } if (!validate::check($validate, $objData)) { $this->JsonReturn(validate::getError()); } //补充数据 $objData['refresh_time'] = TIME; $objData['start_times'] = inTime($objData['start_times']); $objData['end_times'] = inTime($objData['end_times']); // z($objData); //判断重复 // $checkHas = M('ste_goods')->where(array('goods_name' => $objData['goods_name'], // 'goods_spec' => $objData['goods_spec'], 'shop_id' => $rs['shop_id'], 'status' => 1))->getField('gid'); // if ($checkHas && $checkHas != $id) { // $this->JsonReturn('同名商品已存在,请检查'); // } //同步店铺信息 $objData['service_id'] = M('ste_shop')->where(array('shop_id' => $rs['shop_id']))->getField('service_id'); // z($objData); M('ste_goods')->update($objData, array('gid' => $id)); //===记录操作日志==== parent::saveSySLog(2, $objData, $id, array('gid' => $id), '商品管理-编辑'); //===记录操作日志==== $this->JsonReturn('ok', null, 1); }