stituation_110_2

This commit is contained in:
dengbw
2022-01-10 17:22:31 +08:00
parent 7622667be7
commit 1ed9d8ab64
5 changed files with 183 additions and 52 deletions
+89 -37
View File
@@ -13,6 +13,7 @@ class Situation extends HD_Controller
{
parent::__construct();
$this->load->model("biz/biz_model", 'mdBiz');
$this->load->model("biz/biz_brand_model", 'mdBizBrand');
$this->load->model("biz/biz_base_model", 'mdBizBase');
$this->load->model("biz/biz_sell_model", 'mdBizSell');
$this->load->model('area_model', 'mdArea');
@@ -43,7 +44,7 @@ class Situation extends HD_Controller
if (!$re_biz || empty($re_biz)) {
return $this->show_json(SYS_CODE_FAIL, '店铺不存在!');
}
$base_info = $sell_info = [];
$base_info = [];
//店铺概况
$re_base = $this->mdBizBase->get(['biz_id' => $biz_id]);
$fields = $this->mdBizBase->get_fields();
@@ -55,8 +56,15 @@ class Situation extends HD_Controller
} else if ($key == 'street_id' && $re_biz['street_id']) {//乡镇
$result = $this->mdStreet->get(['street_id' => $re_biz['street_id']]);
$fields[$key]['value'] = $result['street_name'];
} else if ($key == 'company' && $re_biz['brand_id']) {//公司名称
$result = $this->mdBizBrand->get(['id' => $re_biz['brand_id']]);
$result['brand_name'] && $fields[$key]['value'] = $result['brand_name'];
} else if ($key == 'level') {//级别
$fields[$key]['value'] = $this->level($biz_id);
} else if ($key == 'type' && $re_biz['type']) {//类型
$fields[$key]['value'] = $this->mdBiz->type_ary($re_biz['type']);
} else if ($key == 'address' && $re_biz['address']) {//位置
$fields[$key]['value'] = $re_biz['address'];
} else if ($key == 'lead' && $re_base[$key]) {//负责人
$result = $this->mdUsers->get(['id' => $re_base[$key]]);
$fields[$key]['value'] = $result['uname'];
@@ -80,43 +88,16 @@ class Situation extends HD_Controller
$base_info[] = $setValue;
}
//售卖概况
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
$jsondata = $re_biz['jsondata'] ? json_decode($re_biz['jsondata'], true) : [];
$y_month = date('Y-m', strtotime("-1 month"));//上个月
$re_sell = $this->mdBizSell->get(['biz_id' => $biz_id, 'y_month' => $y_month]);
$fields = $this->mdBizSell->get_fields();
foreach ($fields as $key => $value) {
if ($key == 'cooperation_car' && $jsondata['auto_brands']) {
$autoBrands = '';
if ($re_sell[$key]) {
$autoBrands = $re_sell[$key];
} else if ($jsondata['auto_brands']) {
// $auto_brands = implode(',', $jsondata['auto_brands']);
// $res_ab = $this->mdAutoBrand->select(["id in({$auto_brands})" => null], 'id desc', 0, 0, 'name');
// $res_ab && $auto_brands = implode(',', array_column($res_ab, 'name'));
}
$fields[$key]['value'] = $autoBrands;
} else if ($key == 'sales') {
$orders = '';
if ($re_sell[$key]) {
$orders = $re_sell[$key];
} else {
// $last_month_s = date("Y-m-01", strtotime("-1 month"));//上1个月1日
// $last_month_e = date("Y-m-d", strtotime("$last_month_s +1 month -1 day")); //上1个月最后一天
// $where = ['biz_id' => $biz_id, 'status<>' => -1, 'brand_id<>' => 3, 'biz_id<>' => 1];
// $orders = $this->mdOrders->count(array_merge($where, ['c_time >=' => strtotime($last_month_s . ' 00:00:00')
// , 'c_time <=' => strtotime($last_month_e . ' 23:59:59')]));
}
$fields[$key]['value'] = $orders;
} else {
$re_sell[$key] && $fields[$key]['value'] = $re_sell[$key];
}
$setValue = $fields[$key];
$setValue['field'] = $key;
$sell_info[] = $setValue;
}
$this->data['base_info'] = $base_info;
$this->data['sell_info'] = $sell_info;
$showInfo['biz_id'] = $biz_id;
$showInfo['sell_info'] = '';
$showInfo['y_month'] = date('Y-m', strtotime("-1 month"));//上个月
$y_month_ary = [];
for ($i = 1; $i <= 12; $i++) {
$y_month_ary[] = date('Y-m', strtotime("-{$i} month"));
}
$showInfo['y_month_ary'] = $y_month_ary;
$this->data['showInfo'] = $showInfo;
$this->data['_title'] = $re_biz['biz_name'];
return $this->show_view('biz/situation/get', true);
}
@@ -142,4 +123,75 @@ class Situation extends HD_Controller
{
}
public function get_sell_info()
{
$biz_id = intval($this->input->post('biz_id'));
$y_month = $this->input->post('y_month');
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
$sell_info = [];
if (!$y_month) {
$y_month = date('Y-m', strtotime("-1 month"));//上个月
}
$re_sell = $this->mdBizSell->get(['biz_id' => $biz_id, 'y_month' => $y_month]);
$fields = $this->mdBizSell->get_fields();
foreach ($fields as $key => $value) {
if ($key == 'boss_sell') {
$fields[$key]['value'] = $re_sell['boss_sell'] ? '是' : '否';
} else {
$re_sell[$key] && $fields[$key]['value'] = $re_sell[$key];
}
$setValue = $fields[$key];
$setValue['field'] = $key;
$sell_info[] = $setValue;
}
$this->data = array('sell_info' => $sell_info);
return $this->show_json(SYS_CODE_SUCCESS);
}
private function level($biz_id = 0)
{
$str = '';
if ($biz_id) {
$where = ['biz_id' => $biz_id, 'status<>' => -1, 'brand_id<>' => 3, 'biz_id<>' => 1];
$last_month_s = date("Y-m-01", strtotime("-1 month"));//上1个月1日
$last_month_e = date("Y-m-d", strtotime("$last_month_s +1 month -1 day")); //上1个月最后一天
$orders = $this->mdOrders->count(array_merge($where, ['c_time >=' => strtotime($last_month_s . ' 00:00:00')
, 'c_time <=' => strtotime($last_month_e . ' 23:59:59')]));
if ($orders >= 12) {
$str = 'A1';
} else if ($orders >= 9) {
$str = 'A2';
} else if ($orders >= 6) {
$str = 'A3';
} else if ($orders >= 5) {
$str = 'B1';
} else if ($orders >= 4) {
$str = 'B2';
} else if ($orders >= 3) {
$str = 'B3';
} else {
$month_s = date("Y-m-01", strtotime("-3 month")); //上3个月1日
$month_e = date("Y-m-d", strtotime("$month_s +1 month -1 day")); //上3个月最后一天
$orders = $this->mdOrders->count(array_merge($where, ['c_time >=' => strtotime($month_s . ' 00:00:00')
, 'c_time <=' => strtotime($month_e . ' 23:59:59')]));
if ($orders && $orders <= 8) {
$str = 'C1';
} else {
$month_s = date("Y-m-d", strtotime("$last_month_s -15 day"));//45天前
$month_e = $last_month_e; //上个月最后一天
$orders = $this->mdOrders->count(array_merge($where, ['c_time >=' => strtotime($month_s . ' 00:00:00')
, 'c_time <=' => strtotime($month_e . ' 23:59:59')]));
if ($orders == 1) {
$str = 'C2';
} else if ($orders == 0) {
$this->load->model('items/items_model', 'mdItems');
$count_items = $this->mdItems->count(['status<>' => 0, 'biz_id' => $biz_id, 'brand_id<>' => 3, 'biz_id<>' => 1]);
!$count_items && $str = 'C3';//门店有样车未开单
}
}
}
}
return $str;
}
}
+1 -1
View File
@@ -316,7 +316,6 @@ class Transfer extends HD_Controller
}
$transport['imgs'] = $imgs;
}
$jsondata['reason'] && $fields[] = ['title' => '调拨理由', 'value' => $jsondata['reason']];
if ($re['arti_id']) {
$res_a = $this->mdArticle->select(["id in ({$re['arti_id']})" => null], 'id desc', 0, 0, 'title');
$res_a && $arti_content = implode(' &nbsp;&nbsp;', array_unique(array_column($res_a, 'title')));
@@ -333,6 +332,7 @@ class Transfer extends HD_Controller
}
$abnormal['imgs'] = $imgs;
}
$jsondata['reason'] && $fields[] = ['title' => '调拨理由', 'value' => $jsondata['reason']];
if ($re['trailer_fees']) {
$trailer_fees = $re['trailer_fees'] ? $re['trailer_fees'] . '元' : '';
$trailer_fees .= '&nbsp;&nbsp;费用承担人:' . $this->mdTransfer->feesTypeAry($re['fees_type']);
+81 -8
View File
@@ -40,14 +40,25 @@
<? } ?>
<? } ?>
</div>
<div class="am-tab-panel" style="padding-left: 20px">
<? foreach ($sell_info
as $key => $value) { ?>
<div class="am-form-inline" style="line-height: 37px;font-size: 1.6rem;">
<?= $value['title'] ?>
<?= $value['value'] ?><?= $value['tag'] ? $value['tag'] : '' ?>
<div class="am-tab-panel" style="padding: 20px">
<template v-for="(v,i) in showInfo.sell_info">
<div class="am-form-inline" style="line-height: 37px;font-size: 1.6rem;"
v-if="v.field=='y_month'">
<table>
<tr>
<td>{{v.title}} </td>
<td><select v-model="showInfo.y_month" style="width: 150px;"
@change="yMonth">
<option v-for="(v,i) in showInfo.y_month_ary" :value="v">{{v}}
</option>
</select></td>
</tr>
</table>
</div>
<? } ?>
<div v-else class="am-form-inline" style="line-height: 37px;font-size: 1.6rem;">
{{v.title}} {{v.value}}
</div>
</template>
</div>
</div>
</div>
@@ -56,4 +67,66 @@
</div>
</div>
</div>
</div>
</div>
<script>
var vue_obj;
$(document).ready(function () {
vue_obj = new Vue({
el: '#vue-edit',
data: {
showInfo: {'sell_info': [], 'y_month': ''},
},
mounted: function () {
var that = this;
that.showInfo = <?=json_encode($showInfo)?>;
that.get_sell_info(that.showInfo.y_month, 0);
},
computed: {},
created: function () {
},
updated: function () {
},
methods: {
get_sell_info: function (y_month, type) {
var vm = this;
$.ajax({
url: '/biz/situation/get_sell_info',
type: 'post',
dataType: 'json',
data: {
biz_id: vm.showInfo.biz_id,
y_month: y_month,
},
beforeSend: function () {
if (type == 1) {
layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
}
},
complete: function () {
if (type == 1) {
layer.closeAll('loading');
}
},
success: function (res) {
if (res['code']) {
vm.showInfo.sell_info = res.data.sell_info;
}
}
});
},
yMonth: function () {
var vm = this;
vm.get_sell_info(vm.showInfo.y_month, 1);
}
},
watch: {
// 'showInfo.y_month': function (nv, ov) {
// var that = this;
// that.get_sell_info(nv);
// },
}
});
});
</script>
+4 -3
View File
@@ -142,7 +142,8 @@
</tr>
<tr>
<td colspan="5" class="align-r">
<!-- <a data-open="/biz/situation/get?id=--><?//= $v['id'] ?><!--" class="am-btn am-btn-primary am-btn-xs">概况</a>-->
<a data-open="/biz/situation/get?id=<?= $v['id'] ?>"
class="am-btn am-btn-primary am-btn-xs">概况</a>
<a href="javascript:void(0);" class="am-btn am-btn-primary am-btn-xs"
@click="channel_modal(<?= $v['id'] ?>)">渠道归属</a>
<a href="javascript:void(0);" class="am-btn am-btn-primary am-btn-xs"
@@ -276,7 +277,7 @@
});
layer.open({
type: 1,
area: ['50%','40%'], //宽高
area: ['50%', '40%'], //宽高
content: $('#channel-modal'),
title: '渠道归属',
shade: false,
@@ -306,7 +307,7 @@
vm.users_group();
layer.open({
type: 1,
area: ['50%','50%'], //宽高
area: ['50%', '50%'], //宽高
content: $('#biz_manage-modal'),
title: '门店管理员',
shade: false,
+8 -3
View File
@@ -74,19 +74,24 @@ class Biz extends Wxapp
],
[
'brand_id' => 4, 'cms_id' => 0, 'sort' => 0,
'title' => '哪吒V', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '63900 ~ 72900'],
'title' => '哪吒V', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '65900 ~ 74900'],
'img' => 'https://img.liche.cn/NZV.png'
],
[
'brand_id' => 5, 'cms_id' => 0, 'sort' => 0,
'title' => '零跑T03', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '59800 ~ 76800'],
'title' => '零跑T03', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '60800 ~ 84900'],
'img' => 'https://img.liche.cn/T03.png'
],
[
'brand_id' => 5, 'cms_id' => 0, 'sort' => 0,
'title' => '零跑C11', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '159800 ~ 199800'],
'title' => '零跑C11', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '159800 ~ 214800'],
'img' => 'https://img.liche.cn/C11.png'
],
[
'brand_id' => 7, 'cms_id' => 0, 'sort' => 0,
'title' => '合创Z03', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '132800 ~ 168800'],
'img' => 'https://img.liche.cn/HCZ03.png'
],
];
shuffle($lists);
foreach ($lists as $key => $val) {