Commit 7a596b09 authored by clone's avatar clone

数据转换

parent febf23e7
......@@ -57,14 +57,16 @@ class ConvertOrder extends Basic
set_time_limit(0);
//todo old num convert new table. first select page report num.
//$params = $this->params;
$time_ = array( 'between', array( "2016-04-18 23:59:59", "2018-04-17 23:59:59" ) );
$total = $this->appliesModel->getAppliesCount();
$total = $this->appliesModel->getAppliesCount([ "a.created" => $time_ ]);
$pageSize = 200;
$pageTotal = ceil($total / $pageSize);
$field = "a.id,a.phpone,a.agent_id,a.agent_shop_id,a.receptiontime ,a.house_id,a.customer,a.sex,a.vehicle,a.created,a.modified,
b.title as house_title,b.room_num_left,c.phone,c.realname";
for ($pageNo = 1; $pageNo <= $pageTotal; $pageNo++) {
$appliesList = $this->appliesModel->getApplies($pageNo, $pageSize, $field);
$appliesList = $this->appliesModel->getApplies($pageNo, $pageSize, $field, [ "a.created" => $time_ ]);
if (count($appliesList) > 0) {
$orderArr = [];
foreach ($appliesList as $item) {
......@@ -75,7 +77,7 @@ class ConvertOrder extends Basic
, $userInfo["user_name"], $item["vehicle"], $item["agent_shop_id"], $item["receptiontime"], $item["created"], $item["modified"]);
$f_id = $this->reportModel->addReport($reportParam);
if ($f_id > 0) {
$orderParam = $this->orderBin($this->createOrderNumber(), $f_id, $item["house_id"],$item["created"], $item["modified"]);
$orderParam = $this->orderBin($this->createOrderNumber(), $f_id, $item["house_id"], $item["created"], $item["modified"]);
array_push($orderArr, $orderParam);
}
}
......@@ -94,13 +96,15 @@ class ConvertOrder extends Basic
public function convertMarchIn()
{
set_time_limit(0);
$total = $this->remarksModel->getRemarksCount();
$time_ = array( 'between', array( "2016-04-18 23:59:59", "2018-04-17 23:59:59" ) );
$total = $this->remarksModel->getRemarksCount([ "a.created" => $time_ ]);
$pageSize = 200;
$pageTotal = ceil($total / $pageSize);
$field = "a.shopuser_id,b.id as report_id,c.id as order_id,c.order_no,a.content,d.imagename,a.content_area,a.created,a.modified";
$marchInArr = [];
for ($pageNo = 1; $pageNo <= $pageTotal; $pageNo++) {
$marchInList = $this->remarksModel->getRemarksList($pageNo, $pageSize, $field);
$marchInList = $this->remarksModel->getRemarksList($pageNo, $pageSize, $field, [ "a.created" => $time_ ]);
foreach ($marchInList as $key => $item) {
$marchInParams = $this->marchInBin($item["shopuser_id"], $item["report_id"], $item["order_id"], $item["order_no"],
$item["content"], $item["imagename"], $item["content_area"], $item["created"], $item["modified"]);
......@@ -115,10 +119,10 @@ class ConvertOrder extends Basic
public function convertCollectingBill()
{
set_time_limit(0);
$time_ = array( 'between', array( "2016-04-18 23:59:59", "2018-01-18 23:59:59" ) );
$field = "a.type,a.moneytype,a.money,a.trademark,a.remarks,a.created,a.modified,d.id as agent_id,b.id as report_id,c.id as order_id,c.order_no";
$collectingBillList = $this->journalaccountsModel->getJournalAccountsListByStatus(1, 2000, $field);
dump($collectingBillList);exit;
$collectingBillArr = [];
$collectingBillList = $this->journalaccountsModel->getJournalAccountsListByStatus(1, 2000, $field, [ "a.created" => $time_ ]);
$collectingBillArr = [];
foreach ($collectingBillList as $key => $item) {
$collectingBillParams = $this->collectingBillBin(0, $item["moneytype"], $item["type"], $item["money"],
$item["agent_id"], $item["report_id"], $item["order_id"], $item["order_no"], "---", $item["trademark"],
......@@ -277,7 +281,7 @@ class ConvertOrder extends Basic
* @param $update_time
* @return mixed
*/
private function orderBin($order_no, $f_id, $house_id,$create_time,$update_time)
private function orderBin($order_no, $f_id, $house_id, $create_time, $update_time)
{
$houseModel = new GHouses();
$houseResult = $houseModel->getHouseDetail("id,internal_title", [ "id" => $house_id ]);
......
......@@ -24,8 +24,9 @@ class Applies extends Model
->select();
}
public function getApplies($pageNo, $pageSize, $field)
public function getApplies($pageNo, $pageSize, $field, $params)
{
$where_ = $params;
$where_["transaction_status"] = 0;
return Db::table($this->table)
->field($field)
......@@ -37,9 +38,12 @@ class Applies extends Model
->page($pageNo)
->select();
}
public function getAppliesCount()
public function getAppliesCount($params)
{
$where_ = $params;
$where_["transaction_status"] = 0;
return $this
->field("a.id")
->alias("a")
......
......@@ -109,19 +109,21 @@ class JournalAccounts extends Model
->select();
}
public function getJournalAccountsListByStatus($pageNo = 1, $pageSize = 15, $field)
public function getJournalAccountsListByStatus($pageNo = 1, $pageSize = 15, $field,$params)
{
$params["a.transaction_status"] = array("in","2,3");
return $this->db
$result = $this->db
->field($field)
->alias("a")
->join('o_report b', 'a.apply_id = b.id', 'right')
->join('o_order c', 'b.id = c.f_id', 'right')
->join('agents d', 'a.operaaccount = d.realname', 'LEFT')
->join('a_agents d', 'a.operaaccount = d.name', 'LEFT')
->where($params)
->limit($pageSize)
->page($pageNo)
->select();
//echo $this->db->getLastSql();
return $result;
}
}
......@@ -4,9 +4,11 @@ namespace app\model;
use think\Model;
use think\Db;
class Remarks extends Model
{
protected $table = "remarks";
/**
* 成交记录列表
*
......@@ -21,7 +23,8 @@ class Remarks extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getJournalHouseInfo($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $agent_id = '') {
public function getJournalHouseInfo($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $agent_id = '')
{
$result = $this->field($field)
->where('shopuser_id', $agent_id)
......@@ -36,18 +39,18 @@ class Remarks extends Model
//查找商铺或街铺的名字和图片
foreach ($result as $key => $value) {
$data[$key] = Db::table('houseinfos')
->field($fields_houinfo)->where('id',$value['house_id'])->find();
->field($fields_houinfo)->where('id', $value['house_id'])->find();
$data[$key]['singntime'] = $value['created'] ? date('Y-m-d',strtotime($value['created'])) : "";
$data[$key]['shangpu_tags'] = explode(',',$data[$key]['shangpu_tags']);
$data[$key]['singntime'] = $value['created'] ? date('Y-m-d', strtotime($value['created'])) : "";
$data[$key]['shangpu_tags'] = explode(',', $data[$key]['shangpu_tags']);
$img = Db::table('houseimgs')->field('imagename')
->where('house_id', $value['house_id'])->where('imgtype',1)->find();
->where('house_id', $value['house_id'])->where('imgtype', 1)->find();
if ($img['imagename']) {
$data[$key]['img'] = ADMIN_URL_TL.'/houseImg/'.$img['imagename'];
$data[$key]['img'] = ADMIN_URL_TL . '/houseImg/' . $img['imagename'];
} else {
$data[$key]['img'] = ADMIN_URL_TL.'/resource/image/pzz_.jpg';
$data[$key]['img'] = ADMIN_URL_TL . '/resource/image/pzz_.jpg';
}
}
......@@ -64,7 +67,8 @@ class Remarks extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getJournalHouseInfoId($fields = '', $params) {
public function getJournalHouseInfoId($fields = '', $params)
{
$result = $this->field($fields)
->where($params)
->group('apply_id')
......@@ -77,9 +81,9 @@ class Remarks extends Model
* @param $params
* @return int|string
*/
public function getTotal2($join,$params)
public function getTotal2($join, $params)
{
return $this->alias('r')
return $this->alias('r')
->join($join)
->where($params)->count();
}
......@@ -96,7 +100,7 @@ class Remarks extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getListJoin($p = 1, $pageSize = 15, $order_ = 'id desc', $field = '',$join='', $where = '')
public function getListJoin($p = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $join = '', $where = '')
{
$data = $this->field($field)
->alias('r')
......@@ -107,13 +111,13 @@ class Remarks extends Model
->page($p)
->select();
//echo $this->getLastSql();
if(!$data){
if (!$data) {
return $data;
}
/****************************处理客户电话****************************************/
foreach($data as $k=> $li) {
$phonestr = htmlentities(trim($li["phpone"]));
$phonearr = explode('|', $phonestr);
foreach ($data as $k => $li) {
$phonestr = htmlentities(trim($li["phpone"]));
$phonearr = explode('|', $phonestr);
$customer_phone = '';
foreach ($phonearr as $v) {
if ($v) {
......@@ -126,8 +130,9 @@ class Remarks extends Model
return $data;
}
public function getRemarksList($pageNo, $pageSize, $field)
public function getRemarksList($pageNo, $pageSize, $field, $params)
{
$where_ = $params;
$where_["a.isinstatus"] = 1;
return Db::table($this->table)
->field($field)
......@@ -140,8 +145,10 @@ class Remarks extends Model
->page($pageNo)
->select();
}
public function getRemarksCount()
public function getRemarksCount($params)
{
$where_ = $params;
$where_["a.isinstatus"] = 1;
return Db::table($this->table)
->field("a.id")
......
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