|
@@ -915,9 +915,70 @@ class Buy
|
|
|
|
|
|
$shop = Dever::db('shop/info')->find($info['type_id']);
|
|
$shop = Dever::db('shop/info')->find($info['type_id']);
|
|
|
|
|
|
- $data = $this->assign($goods, $info, $shop);
|
|
|
|
|
|
+ list($data, $source) = $this->assign($goods, $info, $shop, true);
|
|
|
|
|
|
- print_r($data);die;
|
|
|
|
|
|
+ if ($data) {
|
|
|
|
+ $head = array('序号', '商品编号', '商品名称', '供货商', '订货总数量', '商品计量单位', '订货单总金额');
|
|
|
|
+ $body = array();
|
|
|
|
+ $i = 0;
|
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
|
+ foreach ($v as $v1) {
|
|
|
|
+ $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']);
|
|
|
|
+ if (isset($goods_info['sku'])) {
|
|
|
|
+ $sku = '[' . $goods_info['sku']['string'] . ']';
|
|
|
|
+ } else {
|
|
|
|
+ $sku = '';
|
|
|
|
+ }
|
|
|
|
+ $d = array
|
|
|
|
+ (
|
|
|
|
+ $i+1,
|
|
|
|
+ $goods_info['code'],
|
|
|
|
+ $goods_info['name'] . $sku,
|
|
|
|
+ $v1['source_name'],
|
|
|
|
+ $v1['num'],
|
|
|
|
+ $goods_info['unit'],
|
|
|
|
+ $v1['p_price'] * $v1['num'],
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $body[] = $d;
|
|
|
|
+
|
|
|
|
+ $i++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ($goods) {
|
|
|
|
+ foreach ($goods as $k => $v) {
|
|
|
|
+ $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v['goods_id'], $v['sku_id']);
|
|
|
|
+ if (isset($goods_info['sku'])) {
|
|
|
|
+ $sku = '[' . $goods_info['sku']['string'] . ']';
|
|
|
|
+ } else {
|
|
|
|
+ $sku = '';
|
|
|
|
+ }
|
|
|
|
+ $d = array
|
|
|
|
+ (
|
|
|
|
+ $i+1,
|
|
|
|
+ $goods_info['code'],
|
|
|
|
+ $goods_info['name'] . $sku,
|
|
|
|
+ '无',
|
|
|
|
+ $v['num'],
|
|
|
|
+ $goods_info['unit'],
|
|
|
|
+ $v['p_price'] * $v['num'],
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $body[] = $d;
|
|
|
|
+
|
|
|
|
+ $i++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $result['商品拆单'] = array
|
|
|
|
+ (
|
|
|
|
+ 'type' => 'table',
|
|
|
|
+ 'content' => array
|
|
|
|
+ (
|
|
|
|
+ 'head' => $head,
|
|
|
|
+ 'body' => $body,
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
$url = Dever::url('lib/buy.refund_commit?json=1', 'mshop');
|
|
$url = Dever::url('lib/buy.refund_commit?json=1', 'mshop');
|
|
if (!$info['refund_cash']) {
|
|
if (!$info['refund_cash']) {
|
|
@@ -1576,7 +1637,7 @@ class Buy
|
|
return 'ok';
|
|
return 'ok';
|
|
}
|
|
}
|
|
|
|
|
|
- public function assign(&$goods, &$order, $shop)
|
|
|
|
|
|
+ public function assign(&$goods, &$order, $shop, $state = false)
|
|
{
|
|
{
|
|
if (strstr($order['order_num'], '_')) {
|
|
if (strstr($order['order_num'], '_')) {
|
|
$temp = explode('_', $order['order_num']);
|
|
$temp = explode('_', $order['order_num']);
|
|
@@ -1586,15 +1647,19 @@ class Buy
|
|
$order['order_index'] = 0;
|
|
$order['order_index'] = 0;
|
|
}
|
|
}
|
|
# 获取门店分配的仓库和工厂
|
|
# 获取门店分配的仓库和工厂
|
|
- $data = array();
|
|
|
|
|
|
+ $data = $source = array();
|
|
|
|
+
|
|
|
|
+ $this->assign_store($data, $goods, $source, $order, $shop);
|
|
|
|
+ $this->assign_factory($data, $goods, $source, $order, $shop);
|
|
|
|
|
|
- $this->assign_store($data, $goods, $order, $shop);
|
|
|
|
- $this->assign_factory($data, $goods, $order, $shop);
|
|
|
|
|
|
+ if ($state) {
|
|
|
|
+ return array($data, $source);
|
|
|
|
+ }
|
|
|
|
|
|
return $data;
|
|
return $data;
|
|
}
|
|
}
|
|
|
|
|
|
- private function assign_store(&$data, &$goods, $order, $shop)
|
|
|
|
|
|
+ private function assign_store(&$data, &$goods, &$source, $order, $shop)
|
|
{
|
|
{
|
|
$shop_store = Dever::db('shop/store')->select(array('shop_id' => $shop['id']));
|
|
$shop_store = Dever::db('shop/store')->select(array('shop_id' => $shop['id']));
|
|
$store = array();
|
|
$store = array();
|
|
@@ -1614,6 +1679,8 @@ class Buy
|
|
array_multisort($distance, SORT_ASC, SORT_NUMERIC, $store);
|
|
array_multisort($distance, SORT_ASC, SORT_NUMERIC, $store);
|
|
|
|
|
|
foreach ($store as $k => $v) {
|
|
foreach ($store as $k => $v) {
|
|
|
|
+ $store[$k]['type'] = 2;
|
|
|
|
+ $source[] = $source[$k];
|
|
if ($goods) {
|
|
if ($goods) {
|
|
foreach ($goods as $gk => $gv) {
|
|
foreach ($goods as $gk => $gv) {
|
|
$where = array();
|
|
$where = array();
|
|
@@ -1650,10 +1717,12 @@ class Buy
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return $store;
|
|
}
|
|
}
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
- private function assign_factory(&$data, &$goods, $order, $shop)
|
|
|
|
|
|
+ private function assign_factory(&$data, &$goods, &source, $order, $shop)
|
|
{
|
|
{
|
|
$shop_factory = Dever::db('shop/factory')->select(array('shop_id' => $shop['id']));
|
|
$shop_factory = Dever::db('shop/factory')->select(array('shop_id' => $shop['id']));
|
|
$factory = array();
|
|
$factory = array();
|
|
@@ -1673,6 +1742,8 @@ class Buy
|
|
array_multisort($distance, SORT_ASC, SORT_NUMERIC, $factory);
|
|
array_multisort($distance, SORT_ASC, SORT_NUMERIC, $factory);
|
|
|
|
|
|
foreach ($factory as $k => $v) {
|
|
foreach ($factory as $k => $v) {
|
|
|
|
+ $factory[$k]['type'] = 3;
|
|
|
|
+ $source[] = $factory[$k];
|
|
if ($goods) {
|
|
if ($goods) {
|
|
foreach ($goods as $gk => $gv) {
|
|
foreach ($goods as $gk => $gv) {
|
|
$where = array();
|
|
$where = array();
|
|
@@ -1706,7 +1777,10 @@ class Buy
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return $factory;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|