Commit e96349c0 authored by 蒋林's avatar 蒋林

记录日志; 配置文件

parent 02b3b5bd
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['dsn'] The full DSN string describe a connection to the database.
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database driver. e.g.: mysqli.
| Currently supported:
| cubrid, ibase, mssql, mysql, mysqli, oci8,
| odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Query Builder class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
| ['cachedir'] The path to the folder where cache files should be stored
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
| NOTE: For MySQL and MySQLi databases, this setting is only used
| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
| (and in table creation queries made with DB Forge).
| There is an incompatibility in PHP with mysql_real_escape_string() which
| can make your site vulnerable to SQL injection if you are using a
| multi-byte character set and are running versions lower than these.
| Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
| ['encrypt'] Whether or not to use an encrypted connection.
|
| 'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
| 'mysqli' and 'pdo/mysql' drivers accept an array with the following options:
|
| 'ssl_key' - Path to the private key file
| 'ssl_cert' - Path to the public key certificate file
| 'ssl_ca' - Path to the certificate authority file
| 'ssl_capath' - Path to a directory containing trusted CA certificats in PEM format
| 'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
| 'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not ('mysqli' only)
|
| ['compress'] Whether or not to use client compression (MySQL only)
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
| - good for ensuring strict SQL while developing
| ['ssl_options'] Used to set various SSL options that can be used when making SSL connections.
| ['failover'] array - A array with 0 or more data for connections if the main should fail.
| ['save_queries'] TRUE/FALSE - Whether to "save" all executed queries.
| NOTE: Disabling this will also effectively disable both
| $this->db->last_query() and profiling of DB queries.
| When you run a query, with this setting set to TRUE (default),
| CodeIgniter will store the SQL statement for debugging purposes.
| However, this may cause high memory usage, especially if you run
| a lot of SQL queries ... disable this to avoid that problem.
|
| The $active_group variable lets you choose which connection group to
| make active. By default there is only one group (the 'default' group).
|
| The $query_builder variables lets you determine whether or not to load
| the query builder class.
*/
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => '192.168.1.181',
'username' => 'pp_share',
'password' => '123456',
'database' => 'pp_wxh',
'dbdriver' => 'mysqli',
'dbprefix' => 'wxh_',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['dsn'] The full DSN string describe a connection to the database.
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database driver. e.g.: mysqli.
| Currently supported:
| cubrid, ibase, mssql, mysql, mysqli, oci8,
| odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Query Builder class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
| ['cachedir'] The path to the folder where cache files should be stored
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
| NOTE: For MySQL and MySQLi databases, this setting is only used
| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
| (and in table creation queries made with DB Forge).
| There is an incompatibility in PHP with mysql_real_escape_string() which
| can make your site vulnerable to SQL injection if you are using a
| multi-byte character set and are running versions lower than these.
| Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
| ['encrypt'] Whether or not to use an encrypted connection.
|
| 'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
| 'mysqli' and 'pdo/mysql' drivers accept an array with the following options:
|
| 'ssl_key' - Path to the private key file
| 'ssl_cert' - Path to the public key certificate file
| 'ssl_ca' - Path to the certificate authority file
| 'ssl_capath' - Path to a directory containing trusted CA certificats in PEM format
| 'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
| 'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not ('mysqli' only)
|
| ['compress'] Whether or not to use client compression (MySQL only)
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
| - good for ensuring strict SQL while developing
| ['ssl_options'] Used to set various SSL options that can be used when making SSL connections.
| ['failover'] array - A array with 0 or more data for connections if the main should fail.
| ['save_queries'] TRUE/FALSE - Whether to "save" all executed queries.
| NOTE: Disabling this will also effectively disable both
| $this->db->last_query() and profiling of DB queries.
| When you run a query, with this setting set to TRUE (default),
| CodeIgniter will store the SQL statement for debugging purposes.
| However, this may cause high memory usage, especially if you run
| a lot of SQL queries ... disable this to avoid that problem.
|
| The $active_group variable lets you choose which connection group to
| make active. By default there is only one group (the 'default' group).
|
| The $query_builder variables lets you determine whether or not to load
| the query builder class.
*/
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => '192.168.1.181',
'username' => 'pp_share',
'password' => '123456',
'database' => 'pp_wxh',
'dbdriver' => 'mysqli',
'dbprefix' => 'wxh_',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['dsn'] The full DSN string describe a connection to the database.
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database driver. e.g.: mysqli.
| Currently supported:
| cubrid, ibase, mssql, mysql, mysqli, oci8,
| odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Query Builder class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
| ['cachedir'] The path to the folder where cache files should be stored
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
| NOTE: For MySQL and MySQLi databases, this setting is only used
| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
| (and in table creation queries made with DB Forge).
| There is an incompatibility in PHP with mysql_real_escape_string() which
| can make your site vulnerable to SQL injection if you are using a
| multi-byte character set and are running versions lower than these.
| Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
| ['encrypt'] Whether or not to use an encrypted connection.
|
| 'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
| 'mysqli' and 'pdo/mysql' drivers accept an array with the following options:
|
| 'ssl_key' - Path to the private key file
| 'ssl_cert' - Path to the public key certificate file
| 'ssl_ca' - Path to the certificate authority file
| 'ssl_capath' - Path to a directory containing trusted CA certificats in PEM format
| 'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
| 'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not ('mysqli' only)
|
| ['compress'] Whether or not to use client compression (MySQL only)
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
| - good for ensuring strict SQL while developing
| ['ssl_options'] Used to set various SSL options that can be used when making SSL connections.
| ['failover'] array - A array with 0 or more data for connections if the main should fail.
| ['save_queries'] TRUE/FALSE - Whether to "save" all executed queries.
| NOTE: Disabling this will also effectively disable both
| $this->db->last_query() and profiling of DB queries.
| When you run a query, with this setting set to TRUE (default),
| CodeIgniter will store the SQL statement for debugging purposes.
| However, this may cause high memory usage, especially if you run
| a lot of SQL queries ... disable this to avoid that problem.
|
| The $active_group variable lets you choose which connection group to
| make active. By default there is only one group (the 'default' group).
|
| The $query_builder variables lets you determine whether or not to load
| the query builder class.
*/
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => '192.168.1.35',
'username' => 'test_wxh',
'password' => '8v@XRSQ#EMVo!JdRUK@xvZ#Lk',
'database' => 'test_wxh',
'dbdriver' => 'mysqli',
'dbprefix' => 'wxh_',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
......@@ -17,7 +17,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
* @property api_log_model api_log_model
* @property ReceiveGalanz ReceiveGalanz
*/
class Galanz extends CI_Controller
class Galanz extends BaseController
{
protected static $receiveGalanzObj = null;
......
This diff is collapsed.
<?php
/**
* Created by PhpStorm.
* User: LinJiangL
* Date: 16/8/18
* Time: 下午2:00
*/
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Class Galanz 计划任务
*
* @property galanz_model galanz_model
* @property PushGalanz PushGalanz
* @property SourceGalanz SourceGalanz
*/
class Galanz extends BaseController
{
public function __construct()
{
parent::__construct();
}
/**
* 定时抓取订单数据
*/
public function index()
{
ini_set("max_execution_time", 12000);
//账号配置
$accountConfig = [
[
'username' => 'c01000005', //用户名
'pwd' => 'weixiuhui010', //密码
'city' => '北京', //地区
'category' => '热水器', //产品类型
]
];
$orders = [];
foreach ($accountConfig as $v) {
$orders[] = $this->galanzHandle($v);
}
echo "<pre>";
print_r($orders);
}
private function galanzHandle($account)
{
$this->load->model('galanz_model');
$this->load->library('Source/SourceGalanz', $account, 'SourceGalanz');
//调取最近的数据
$maxTimeOrder = $this->galanz_model->infoMaxDaytime();
$nowTime = date("Y/m/d", time());
if ($maxTimeOrder) {
$startTime = strtotime(date("Y/m/d", $maxTimeOrder['new_callintime']));
$startTime = date("Y/m/d", $startTime);
} else {
//前三天的时间
$startTime = date("Y/m/d", strtotime($nowTime) - 86400 * 2);
}
$endTime = date("Y/m/d", strtotime($nowTime) + 86400);
$orders = $this->SourceGalanz->SearchOrder($startTime, $endTime);
if (empty($orders)) {
return false;
}
$result = [];
foreach ($orders as $k => $v) {
$order = $this->SourceGalanz->OrderDetail($v[0]);
//如果订单存在, 不需要保存
$info = $this->galanz_model->infoByNewName($order['new_name']);
if (empty($info)) {
$id = $this->galanz_model->add($order);
//记录插入的订单
$order['id'] = $id;
$result[$k] = $order;
}
}
return $result;
}
/**
* 推送订单到维修汇
*/
public function pushOrder()
{
$this->load->model('galanz_model');
$this->load->library('Push/PushGalanz', null, 'PushGalanz');
$orders = $this->galanz_model->getOrderList();
foreach ($orders as $k => $v) {
$result = $this->PushGalanz->PushOrder($v);
//推送成功, 修改推送状态
if ($result['code'] == 200 && $result['data'] == 'OK') {
$this->galanz_model->updatePushStatus($v['id']);
}
}
}
}
......@@ -4,13 +4,14 @@ defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Class Welcome
*/
class Welcome extends CI_Controller {
class Welcome extends BaseController {
public function index()
public function order()
{
$this->load->config('account', true);
$account = $this->config->item('account');
$galanzAccount = $account['galanz'];
var_dump($galanzAccount);die();
$this->load->library('Source/SourceGalanz', $galanzAccount['c01000005'], 'SourceGalanz');
......@@ -18,9 +19,15 @@ class Welcome extends CI_Controller {
echo "<pre>";
print_r($order);
}
public function t()
{
$this->load->library('Push/PushGalanz', null, 'PushGalanz');
$result = $this->PushGalanz->GetToken();
print_r($result);
$this->load->model('api_log_model');
$this->api_log_model->add($order['new_id'], '', $order);
}
public function api()
......@@ -29,16 +36,18 @@ class Welcome extends CI_Controller {
$this->load->library('Receive/ReceiveGalanz', null, 'ReceiveGalanz');
$data['appid'] = '10001';
$data['out_trade_no'] = '320423402834023';
$data['out_trade_no'] = 'CALL2016082200544';
$data['nonce_str'] = $this->ReceiveGalanz->GetNonceStr();
$this->ReceiveGalanz->SetValues($data);
//$this->ReceiveGalanz->SetSign();
$this->ReceiveGalanz->SetSign();
$values = $this->ReceiveGalanz->GetValues();
$url = "http://wxh.pp.cn/api/galanz/saveOrder";
$url = "http://testwxh.pp.cc/api/galanz/getOrderDetail";
$result = $this->curlPost($url, $values);
$result['data'] = json_decode($result['data'], true);
echo "<pre>";
print_r($result);
}
......
<?php
/**
* Created by PhpStorm.
* User: LinJiangL
* Date: 16/8/19
* Time: 上午11:14
*/
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Class Galanz 格兰仕相关接口
*
* @property galanz_model galanz_model
* @property PushGalanz PushGalanz
* @property SourceGalanz SourceGalanz
* @property api_log_model api_log_model
* @property ReceiveGalanz ReceiveGalanz
*/
class Galanz extends BaseController
{
protected static $receiveGalanzObj = null;
public function __construct()
{
parent::__construct();
$this->load->library('Receive/ReceiveGalanz', null, 'ReceiveGalanz');
self::$receiveGalanzObj = $this->ReceiveGalanz;
}
private function getAccount($username)
{
$this->load->config('account', true);
$account = $this->config->item('account');
$galanzAccount = $account['galanz'];
return $galanzAccount[$username];
}
public function getOrderDetail()
{
$param = $this->input->post();
//验证参数
self::$receiveGalanzObj->SetValues($param);
self::$receiveGalanzObj->CheckGetOrderDetailValues();
$values = self::$receiveGalanzObj->GetValues();
$this->saveLog('', 'getOrderDetail', $param);
$this->load->model('galanz_model');
$info = $this->galanz_model->infoByNewName($values['out_trade_no']);
if (empty($info)) {
self::$receiveGalanzObj->ReturnMessage('10101', '订单不存在');
}
//订单账号
$account = $this->getAccount($info['new_username']);
//获取订单详情
$this->load->library('Source/SourceGalanz', $account, 'SourceGalanz');
$order = $this->SourceGalanz->OrderDetail($info['new_id']);
self::$receiveGalanzObj->ReturnMessage('10000', '', $order);
}
//保存订单
public function saveOrder()
{
$param = $this->input->post();
//验证参数
self::$receiveGalanzObj->SetValues($param);
self::$receiveGalanzObj->CheckSaveOrderValues();
$this->saveLog('', 'saveOrder', $param);
self::$receiveGalanzObj->ReturnMessage('10000');
}
//拒绝订单
public function refuseOrder()
{
$param = $this->input->post();
//验证参数
self::$receiveGalanzObj->SetValues($param);
self::$receiveGalanzObj->CheckRefuseOrderValues();
$this->saveLog('', 'refuseOrder', $param);
self::$receiveGalanzObj->ReturnMessage('10000');
}
//接受订单
public function acceptOrder()
{
$param = $this->input->post();
//验证参数
self::$receiveGalanzObj->SetValues($param);
self::$receiveGalanzObj->CheckAcceptOrderValues();
$this->saveLog('', 'acceptOrder', $param);
self::$receiveGalanzObj->ReturnMessage('10000');
}
//转录维修单
public function createWorkOrder()
{
$param = $this->input->post();
//验证参数
self::$receiveGalanzObj->SetValues($param);
self::$receiveGalanzObj->CheckCreateWorkOrderValues();
$this->saveLog('', 'createWorkOrder', $param);
self::$receiveGalanzObj->ReturnMessage('10000');
}
//转录安装单
public function createUserprofileOrder()
{
$param = $this->input->post();
//验证参数
self::$receiveGalanzObj->SetValues($param);
self::$receiveGalanzObj->CheckCreateUserprofileOrderValues();
$this->saveLog('', 'createUserprofileOrder', $param);
self::$receiveGalanzObj->ReturnMessage('10000');
}
private function saveLog($search, $method, $data)
{
//记录日志
$this->load->model('api_log_model');
$this->api_log_model->add($search, 'galanz', $method, $data);
}
}
\ No newline at end of file
......@@ -14,40 +14,35 @@ defined('BASEPATH') OR exit('No direct script access allowed');
* @property galanz_model galanz_model
* @property PushGalanz PushGalanz
* @property SourceGalanz SourceGalanz
* @property order_log_model order_log_model
* @property push_log_model push_log_model
*/
class Galanz extends CI_Controller
class Galanz extends BaseController
{
public function __construct()
{
parent::__construct();
}
/**
* 定时抓取订单数据
*/
public function index()
{
ini_set("max_execution_time", 12000);
//账号配置
$accountConfig = [
[
'username' => 'c01000005', //用户名
'pwd' => 'weixiuhui010', //密码
'city' => '北京', //地区
'category' => '热水器', //产品类型
]
];
$orders = [];
foreach ($accountConfig as $v) {
$orders[] = $this->galanzHandle($v);
$this->load->config('account', true);
$account = $this->config->item('account');
$galanzAccount = $account['galanz'];
$this->load->model('order_log_model');
foreach ($galanzAccount as $v) {
$orders = $this->galanzHandle($v);
//添加订单入库日志
if ($orders) {
foreach ($orders as $vv) {
$this->order_log_model->add($vv['new_name'], 'galanz', $vv, $v['username']);
}
}
}
echo "<pre>";
print_r($orders);
}
private function galanzHandle($account)
......@@ -58,15 +53,17 @@ class Galanz extends CI_Controller
//调取最近的数据
$maxTimeOrder = $this->galanz_model->infoMaxDaytime();
$nowTime = date("Y/m/d", time());
if ($maxTimeOrder) {
$startTime = strtotime(date("Y/m/d", $maxTimeOrder['new_callintime']));
$startTime = date("Y/m/d", $startTime);
$endTime = date("Y/m/d", time() + 86400);
} else {
$startTime = '';
$endTime = '';
//前三天的时间
$startTime = date("Y/m/d", strtotime($nowTime) - 86400 * 30);
}
$endTime = date("Y/m/d", strtotime($nowTime) + 86400);
$orders = $this->SourceGalanz->SearchOrder($startTime, $endTime);
if (empty($orders)) {
......@@ -84,7 +81,7 @@ class Galanz extends CI_Controller
//记录插入的订单
$order['id'] = $id;
$result[$k] = $order;
$result[] = $order;
}
}
......@@ -98,10 +95,14 @@ class Galanz extends CI_Controller
{
$this->load->model('galanz_model');
$this->load->library('Push/PushGalanz', null, 'PushGalanz');
$this->load->model('push_log_model');
$orders = $this->galanz_model->getOrderList();
foreach ($orders as $k => $v) {
//添加订单推送日志
$this->push_log_model->add($v['new_name'], 'galanz', $v);
$result = $this->PushGalanz->PushOrder($v);
//推送成功, 修改推送状态
......
<?php
/**
* 基础父控制器
*/
class BaseController extends CI_Controller {
public function __construct() {
parent::__construct();
//自动加载数据库连接
$this->load->database();
}
}
File mode changed from 100644 to 100755
......@@ -10,23 +10,30 @@ class Push
{
protected static $token = '';
public function SetAccessToken($appid, $appsecret)
public function SetToken($appid, $appsecret)
{
$url = "http://www.weixiuhui.cn:8080/STS/rest/partner/token?appid={$appid}&appsecret={$appsecret}";
$result = $this->CurlGet($url);
if ($result && $result['code'] == 200) {
$result['data'] = json_decode($result['data'], true);
self::$token = $result['data']['token'];
} else {
die('token获取失败');
}
}
public function GetToken()
{
return self::$token;
}
protected function CurlGet($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl); //执行cURL抓取页面内容
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
......@@ -39,6 +46,7 @@ class Push
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
$result = curl_exec($curl);
......
......@@ -16,10 +16,9 @@ class PushGalanz extends Push
$appid = 1;
$appsecret = 'e10adc3949ba59abbe56e057f20f883f';
$this->SetAccessToken($appid, $appsecret);
$this->SetToken($appid, $appsecret);
}
public function PushOrder($order)
{
$url = "http://www.weixiuhui.cn:8080/STS/rest/partner/order/". self::$token ."/createOrderFromLocoy";
......@@ -34,7 +33,7 @@ class PushGalanz extends Push
'contact_community_name' => $order['new_countyidname'],
'contact_street_name' => $order['new_townidName'] ?: '-',
'contact_address' => $order['new_address'],
'category_name' => $order['new_product'],
'category_name' => $order['new_category'],
'brand_name' => '格兰仕',
'product_certificate_number' => $order['new_producttype'] ?: '-',
'product_serial_number' => $order['new_csnumber'] ?: '-',
......
......@@ -165,6 +165,19 @@ class Receive
* @return array
*/
public function ReturnMessage($code = '10000', $msg = '', $data = '')
{
echo $this->SetErrorCode($code, $msg, $data);
die();
}
/**
* 返回数据
* @param string $code
* @param string $data
* @param string $msg
* @return array
*/
public function SetErrorCode($code = '10000', $msg = '', $data = '')
{
$error = [
'10000' => 'OK',
......@@ -173,9 +186,9 @@ class Receive
'10999' => '参数错误',
];
$msg = $error[$code] ? : $msg;
$msg = isset($error[$code]) ? $error[$code] : $msg;
echo json_encode(['code' => $code, 'msg' => $msg, 'data' => $data]);
die();
return json_encode(['code' => $code, 'msg' => $msg, 'data' => $data], JSON_UNESCAPED_UNICODE);
}
}
\ No newline at end of file
......@@ -26,6 +26,18 @@ class ReceiveGalanz extends Receive
}
}
/**
* 订单详情
*/
public function CheckGetOrderDetailValues()
{
$this->CheckPublicValues();
if (!array_key_exists('out_trade_no', $this->values) || $this->values['out_trade_no'] == '') {
$this->ReturnMessage('10003', '缺少out_trade_no参数!');
}
}
/**
* 保存订单
*/
......
File mode changed from 100644 to 100755
......@@ -9,16 +9,11 @@ class Api_log_model extends CI_Model
public $table = 'api_log'; //表名
function __construct()
{
parent::__construct();
$this->load->database();
}
public function add($search, $method, $data)
public function add($search, $sys, $method, $data)
{
$insertData = [
'search' => $search,
'sys_name' => $sys,
'method' => $method,
'data' => $data ? json_encode($data) : '',
'created_time' => time()
......
......@@ -9,12 +9,6 @@ class Galanz_model extends CI_Model
public $table = 'galanz'; //表名
function __construct()
{
parent::__construct();
$this->load->database();
}
public function add($data)
{
......@@ -63,6 +57,11 @@ class Galanz_model extends CI_Model
return $this->db->insert_id();
}
public function update($id, $data)
{
$this->db->update($this->table, $data, ['id' => $id]);
}
public function updatePushStatus($id)
{
$this->db->update($this->table, ['push_status' => 1], ['id' => $id]);
......@@ -89,63 +88,4 @@ class Galanz_model extends CI_Model
return $result;
}
public function getAccessToken()
{
$appid = 1;
$appsecret = 'e10adc3949ba59abbe56e057f20f883f';
$url = "http://www.weixiuhui.cn:8080/STS/rest/partner/token?appid={$appid}&appsecret={$appsecret}";
return curl_get($url);
}
public function pushOrder()
{
$token = $this->getAccessToken();
if (empty($token)) {
return 10001;
}
$orders = $this->db->get_where($this->table, ['push_status' => 0, 'new_callintype' => '咨询'])->result_array();
if (empty($orders)) {
return 10002;
}
$url = "http://www.weixiuhui.cn:8080/STS/rest/partner/order/{$token['token']}/createOrderFromLocoy";
foreach ($orders as $v) {
$v['data'] = json_decode($v['data'], true);
$pushData = [
'serial_number' => $v['data']['new_name'],
'contact_name' => $v['data']['new_custname'],
'contact_phone' => $v['data']['new_custmobile'],
'contact_tel' => $v['data']['new_custtel'] ?: '-',
'contact_province_name' => $v['data']['new_provinceidName'],
'contact_city_name' => $v['data']['new_cityidName'],
'contact_community_name' => $v['data']['new_countyidname'],
'contact_street_name' => $v['data']['new_townidName'] ?: '-',
'contact_address' => $v['data']['new_address'],
'category_name' => $v['data']['new_product'],
'brand_name' => '格兰仕',
'product_certificate_number' => $v['data']['new_producttype'] ?: '-',
'product_serial_number' => $v['data']['new_csnumber'] ?: '-',
'product_sales_date' => $v['data']['new_broughtdate'],
'service_content' => $v['data']['new_custdescription'] ?: '-',
'order_service_type' => $v['data']['new_callintype'],
'order_product_count' => $v['data']['new_productqty'] ?: 1,
'partner_code' => 'galanz',
'order_commit_from' => '合作商转单',
];
$temp = curl_post($url, $pushData);
if ($temp['code'] == 200 && $temp['data'] == 'OK') {
$this->updatePushStatus($v['id']);
}
}
return 10000;
}
}
\ No newline at end of file
<?php
/**
* 推送订单日志模型
* Class Api_log_model
*/
class Push_log_model extends CI_Model
{
public $table = 'push_log'; //表名
public function add($search, $sys, $data)
{
$insertData = [
'search' => $search,
'sys_name' => $sys,
'data' => $data ? json_encode($data) : '',
'created_time' => time()
];
$this->db->insert($this->table, $insertData);
return $this->db->insert_id();
}
public function getLogs($search)
{
return $this->db->get_where($this->table, ['search' => $search])->result_array();
}
}
\ No newline at end of file
<?php
/**
* 订单入库日志模型
* Class Order_log_model
*/
class Order_log_model extends CI_Model
{
public $table = 'order_log'; //表名
public function add($search, $sys, $data, $remark = '')
{
$insertData = [
'search' => $search,
'sys_name' => $sys,
'data' => $data ? json_encode($data) : '',
'remark' => $remark,
'created_time' => time()
];
$this->db->insert($this->table, $insertData);
return $this->db->insert_id();
}
public function getLogs($search)
{
return $this->db->get_where($this->table, ['search' => $search])->result_array();
}
}
\ No newline at end of file
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment