Settled.php
7.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
use Action\WebAction;
use WebPlugin\Helpers;
use WebPlugin\AuthCode;
use Shop\SettledModel;
/**
* 商家入驻的控制器
*
* @name SettledController
* @package shop
* @copyright yoho.inc
* @author xiaoxiao.hao <xiaoxiao.hao@yoho.cn>
*/
class SettledController extends WebAction
{
private $_information = array('code' => 400, 'message' => '操作失败,请稍后再试!');
/**
*入住流程
*/
public function indexAction()
{
/// 设置头部数据
$this->setWebNavHeader();
$data = array(
'settledPage' => true
);
$this->_view->display('settled', $data);
}
/**
* 添加申请
*/
public function applyAction()
{
//判断是否登录
$this->auditJumpLogin(true, Helpers::url('/settled/apply', array(), 'shop'));//登录后跳转到申请页
$adpic = array(
'_project' => 'adpic',
'format_str' => array(
)
);
$oneCategory = SettledModel::getOneCategory();
/// 设置头部数据
$this->setWebNavHeader();
$state = $this->get('state' ,0);
$data = array(
'settledPage' => true,
'oneCategory' => isset($oneCategory['data']) ? $oneCategory['data'] : array(),
'uploadKey' => AuthCode::base64_str_encode(AuthCode::encode(json_encode($adpic), 'yohobuy_upload_system')),
'state' => $state
);
$this->_view->display('apply', $data);
}
/**
* 添加申请保存
* @return type
*/
public function applySaveAction()
{
$result = $this->_information;
do {
//判断是否登录
$uid = $this->auditJumpLogin();
$brandName = $this->post('brand-name', '');//品牌名称
$registerStatus = $this->post('register-status', '');//品牌注册情况
$sellerName = $this->post('seller-name', '');//入驻卖家名称
$sellerAddress = $this->post('seller-address');//入驻卖家地址
$zipCode = intval($this->post('zip-code'));//邮编
$contacts = $this->post('contacts');//联系人
$contactPhone = $this->post('contact-phone');//联系电话
$contactEmail = $this->post('contact-email');//联系邮箱
$sellerRole = $this->post('seller-role');//卖家与品牌关系
if ($sellerRole === '') {
$sellerRole = $this->post('orther-seller_role');//其它关系
}
if (empty($brandName) || empty($registerStatus) || empty($sellerName) || empty($zipCode) ||
empty($contacts) || empty($contactPhone) || empty($contactEmail) || empty($sellerRole)) {
$result['message'] = '请输入必填信息';
break;
}
$brandWebsite = $this->post('brand-website');//品牌官网
$onlineShopWebsite = $this->post('online-shop-website');//其他线上店网址
$categoryOne = $this->post('category-one', '');//一级品类
$categoryTwo = $this->post('category-two', '');//二级品类
$categoryPrice = $this->post('category-price', '');//品类价格区间
$categoryInfo = array();
if (isset($categoryOne) && is_array($categoryOne) && is_array($categoryTwo) && is_array($categoryPrice)) {
foreach ($categoryOne as $key => $value){
if ($value === '') {
continue;
}
$categoryInfo[$key]['category_one'] = $value;
$categoryInfo[$key]['category_two'] = $categoryTwo[$key];
$categoryInfo[$key]['category_price'] = $categoryPrice[$key];
}
}
$categoryInfo = json_encode($categoryInfo, true); //品类信息
$billingCycle = $this->post('billing-cycle');//结算周期
$warehouseProvince = $this->post('warehouse-province');//仓库地址省
$warehouseCity = $this->post('warehouse-city');//仓库地址市
$warehouseAddress = $warehouseProvince . ' ' . $warehouseCity; //仓库地址
$originCountry = $this->post('origin-country');//产品产地国家
$originProvince = $this->post('origin-province');//产品产地省
$originCity = $this->post('origin-city');//产品产地市
$producer = $originCountry . ' ' . $originProvince . ' ' . $originCity; //商品产地
$invoiceType = $this->post('invoice-type');//发票类型
$newCycle = $this->post('new-cycle');//上新周期
if ($newCycle === '') {
$newCycle = $this->post('orther-new-cycle');
}
$quarterNum = intval($this->post('quarter-num', 0));//每季度可提供数量
$supplyCycle = $this->post('supply-cycle');//补货周期
if ($supplyCycle === '') {
$supplyCycle = $this->post('orther-supply-cycle');
}
$haveStore = intval($this->post('have-store', 0));//是否有线下店
$storeAddress = $this->post('store-address');//线下店地址
$storeSalesVolume = $this->post('store-sales-volume');//线下店月销售额
$storeInfo = array();
if ($haveStore && is_array($storeAddress) && is_array($storeSalesVolume)) {
foreach ($storeAddress as $k => $v){
if ($v === '') {
continue;
}
$storeInfo[$k]['store_address'] = $v;
$storeInfo[$k]['store_sales_volume'] = $storeSalesVolume[$k];
}
}
$storeInfo = json_encode($storeInfo, true);
$brandMaterial = $this->post('brand-material', '');//品牌资料地址
$goodsMaterial = $this->post('goods-material', '');//产品资料地址
$result = SettledModel::insertApply(
$brandName, $registerStatus, $sellerName, $sellerAddress, $zipCode, $contacts, $contactPhone,
$contactEmail, $sellerRole, $brandWebsite, $onlineShopWebsite, $categoryInfo, $billingCycle,
$warehouseAddress, $producer, $invoiceType, $newCycle, $quarterNum, $supplyCycle, $haveStore,
$storeInfo, $brandMaterial, $goodsMaterial, $uid
);
} while (false);
$this->go('/settled/apply?state=' . (isset($result['code']) && $result['code'] === 200));
}
/**
* 一级品类
*/
public function getOneCategoryAction()
{
$result = $this->_information;
$oneCategory = SettledModel::getOneCategory();
if (isset($oneCategory['code']) && $oneCategory['code'] === 200) {
$result = $oneCategory;
}
$this->echoJson($result);
}
/**
* 主要品类--获取二级分类
*/
public function getTwoCategoryAction()
{
$result = $this->_information;
$id = intval($this->get('id'));
do {
if ($id < 1) {
$result['message'] = 'id不能为空';
break;
}
$twoCategory = SettledModel::getTwoCategory($id);
if (isset($twoCategory['code']) && $twoCategory['code'] === 200) {
$result = $twoCategory;
}
} while (false);
$this->echoJson($result);
}
}