/** * 模板消息 */ public function template() { if (IS_AJAX) { self::initWechat(); $list = Template::get(); if ($list) { Db::name('WechatTemplate')->where('status', 'egt', 0)->delete(); foreach ($list['template_list'] as $key => $value) { $value['create_time'] = NOW_TIME; $value['update_time'] = 0; $value['status'] = 1; Db::name('WechatTemplate')->insert($value); } return $this->success(); } else { return $this->error(Wechat::error()); } } else { $list = parent::_list('WechatTemplate'); $this->assign('list', $list); return $this->fetch(); } }
/** * 解析返回的json数据 * @param [type] $json * @return */ private static function parseRequestJson($json) { $result = json_decode($json, true); if (isset($result['errcode'])) { if ($result['errcode'] == 0) { self::$result = $result; return true; } else { Wechat::error(self::parseError($result)); return false; } } else { return $result; } }
/** * 解析支付借口的返回数据 * @param [type] $data [description] */ private static function parsePayResult($data) { if ($data['return_code'] == 'SUCCESS') { if ($data['result_code'] == 'SUCCESS') { return $data; } else { Wechat::error($data['err_code']); return false; } } else { Wechat::error($data['return_msg']); return false; } }